Rework malloc to use a "first fit" algorithm.
authorKevin O'Connor <kevin@koconnor.net>
Sun, 6 Jun 2010 15:10:24 +0000 (11:10 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Sun, 6 Jun 2010 15:10:24 +0000 (11:10 -0400)
commit42a1d4cdb09535d9c5880880af6a17d6741377a6
tree4cf6222680d009e1845c022342a48526ab722987
parent34e9cc5d417442a776ae0e849214bc391c31d0aa
Rework malloc to use a "first fit" algorithm.

The existing malloc implementation effectively uses a stack - all new
allocations come from the top of the stack.  When allocating memory
with a large alignment, the pad used to align the new memory is
unavailable to other users.  Also, memory released by calling free()
is only available to other users when all memory allocated after it is
also freed.

This new malloc scheme uses a first fit approach to finding available
memory.  It makes it possible to use alignment padding and freed space
for new allocations.

This helps reduce the required memory in the permanent memory zones
(ZoneHigh and ZoneLow) where users have the need to allocate
structures with high alignment (eg, virtio and usb).
src/memmap.c
src/memmap.h
src/pmm.c