Mail Archives: djgpp/1996/12/20/15:53:57
Eli Zaretskii writes:
>It has nothing to do with the compiler. It's just a (mis)feature of the
>`malloc' algorithm in DJGPP library (taken from the BSD libc, if memory
>serves). Volunteers are welcome to suggest alternative implementations
>of `malloc' & Co., which are free of this problem.
I've got an implementation of malloc() and co, which has been sitting
around on my hard drive for the last few years (I believe it originated
in the libc for the Atari version of gcc). It uses a linked list of free
memory blocks, and splits off chunks from this when mallocing memory.
The list is sorted, so free() can reinsert the block into the correct
part of the list and merge with adjacent free blocks as required. It's
probably a bit slower than the existing implementation, but doesn't
waste nearly so much memory. If anyone's interested, I can post the
code...
/*
* Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
* Ghoti: 'gh' as in 'enough', 'o' as in 'women', and 'ti' as in 'nation'.
*/
- Raw text -