FS#12412 - Remove firmware/buffer.c, move needed functionality to core_alloc.c
Opened by Boris Gjenero (dreamlayers) - Sunday, 27 November 2011, 21:21 GMT
Last edited by Boris Gjenero (dreamlayers) - Tuesday, 29 November 2011, 01:09 GMT
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);
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.
Tuesday, 29 November 2011, 01:09 GMT
Reason for closing: Accepted
Additional comments about closing: Committed in r31088