Rockbox

This is the bug/patch tracker for Rockbox. Click here for more information.

Quick links: Bugs · Patches · Rockbox frontpage

Tasklist

FS#12412 - Remove firmware/buffer.c, move needed functionality to core_alloc.c

Attached to Project: Rockbox
Opened by Boris Gjenero (dreamlayers) - Sunday, 27 November 2011, 22:21 GMT+2
Last edited by Boris Gjenero (dreamlayers) - Tuesday, 29 November 2011, 02:09 GMT+2
Task Type Patches
Category Operating System/Drivers
Status Closed
Assigned To No-one
Player Type All players
Severity Low
Priority Normal
Reported Version Daily build (which?)
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Private No

Details

Now that core_alloc is used, firmware/buffer.c is almost entirely obsolete. It's only used by core_allocator_init() to tell buflib_init() what memory to use for core_ctx. The contents of the associated header file, firmware/include/buffer.h, are also not needed. It's included by several files, but that's easy to remove. I'm attaching a patch for r31079.

There are currently no other allocations via buffer.c, and allocations could overlap with core_alloc allocations. That's because core_allocator_init() does the following:
void *start = buffer_get_buffer(&size);
buflib_init(&core_ctx, start, size);
buffer_release_buffer(size);
It tells buflib to use the memory and then releases the same memory so allocations via buffer.c can also use it. Yes, one could just remove buffer_release_buffer(size), but what's the point of an allocator which will just call panicf()?

Basically, the benefits are: removing unused code, removing an opportunity for errors, and a simpler future implementation of FS#12403 (when putting .init at the start of the buffer, as kugel suggests).

Note that when files are deleted, you need to rerun "make dep", or else you'll get a "make: *** No rule to make target" error.
   remove_buffer_c.patch (12.7 KiB)
 apps/plugin.c                      |    1 
 apps/recorder/pcm_record.c         |    1 
 apps/gui/skin_engine/skin_engine.c |    1 
 apps/menus/main_menu.c             |    1 
 apps/mp3data.c                     |    1 
 flash/bootbox/main.c               |    2 
 firmware/include/buffer.h          |   38 ------
 firmware/core_alloc.c              |   35 +++++-
 firmware/SOURCES                   |    1 
 firmware/buflib.c                  |    1 
 firmware/thread.c                  |   11 --
 firmware/buffer.c                  |  202 -------------------------------------
 12 files changed, 29 insertions(+), 266 deletions(-)

This task depends upon

Closed by  Boris Gjenero (dreamlayers)
Tuesday, 29 November 2011, 02:09 GMT+2
Reason for closing:  Accepted
Additional comments about closing:  Committed in r31088
Comment by Thomas Martitz (kugel.) - Monday, 28 November 2011, 08:55 GMT+2
Looks good.

Loading...