21 lines
1.3 KiB
Plaintext
21 lines
1.3 KiB
Plaintext
0. Access data structures with accessor macros, then turn the heapinfo
|
|
into several arrays for faster access on machines with addressing modes.
|
|
Also, this eventually raises the possibility of maintaining multiple
|
|
heaps.
|
|
1. Possible heuristic to catch multiple frees. Introduce an extra word
|
|
of heapinfo that says whether the remaining info is for something
|
|
busy or something free. Then we can catch attempts to free already-free
|
|
large blocks, as well as things not belonging to malloc at all. In the
|
|
case of a fragment, we can check if the fragment looks like it *already*
|
|
belongs to the fragment list, by comparing it with the "first" fragment
|
|
of the block, or checking its "prev" pointer to see if it points into
|
|
the block. Then if it looks like it might we can exhaustively search
|
|
the block's free list to see if the fragment is there or not. Extending
|
|
the heapinfo structure would have the benefit of making it a power of
|
|
two and thus making array indexing faster, perhaps. Suitably adapted,
|
|
this heuristic could also catch invalid pointers passed to realloc.
|
|
|
|
All of these additional features require the inclusion of <malloc.h>.
|
|
3. indirect reference allocator: ialloc(), ifree(), irealloc().
|
|
4. garbage collecting allocator: galloc(), garbage(), gfree(), grealloc().
|