[riot-notifications] [RIOT-OS/RIOT] [WIP] Generic memory block allocator (#7651)

Kaspar Schleiser notifications at github.com
Thu Sep 28 11:53:28 CEST 2017


While sth like this useful, I think the implementation has several drawbacks, mostly in the way free blocks are handled.
In the current implementation, every free iterates through all free blocks.

How about this:
- assume the smallest supported blocksize will be 4 bytes (imo it currently does anyways?)
- on initialization, initialize the memory divided into blocks of the desired size as a clist. Use the first four bytes of each block as list entry, and link all the blocks
- reduce the memarray struct to contain a clist entry to the first block
- use simple clist_lpop() / clist_rpush() for alloc/free

That way the actual struct would be down to 4 bytes, and both allocating/deallocating can be done in O(1), also re-using existing code.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/7651#issuecomment-332787579
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20170928/ce862e0f/attachment-0001.html>


More information about the notifications mailing list