PRT.DevelopCodeExplOrigMalloc History

Show minor edits - Show changes to output - Cancel

June 30, 2012, at 04:19 AM by -
Added lines 1-5:
This malloc was written in a hurry, because there's a bug in Linux at the time (might still be there) the standard malloc uses thread-specific stuff, and when a Slave changes the stack, and then migrates to a different core (it runs in a different pthread pinned to that core), free seg-faults.

So, has a single free-list and does a linear search for first chunk big enough, slices off what it needs, and puts rest back as a new chunk.

Has two separate pointer lists for the free list and for neighbor chunks. The pointers for both lists are kept in a pre-amble to the locations returned. When a chunk is allocated, the pointer to next-free chunk is set to zero (I think). So, when free a chunk, have pointers to the chunks on both sides, check the preamble for both, to see which are free vs allocated. If free, combine them with this newly-freed chunk, by changing pointers appropriately.