A freeware heap
We were chasing memory problems through the STL, and shared memory
segments, and strange places that the debugger wouldn't go. I got so
frustrated by this that I wrote my own heap that I could
validate and instrument.
We never used it. The next morning, we took a different approach and
all the problems went away.
Here's the code. Maybe someone will find it useful.
- Source
- Heap.cc
- Distribution
- heap.tar.gz
Features
- A straight
malloc
/free
interface
- Doubly-linked list of blocks
- First-fit clock search
- Extensive integrity checking and diagnostics
- C++ implementation
Notes
If you need routines like calloc
or realloc
,
you can build them on top of malloc
and free
.
The implementation is simple and low-performance.
Nonetheless, it is probably adequate for many applications.
You could wrap the .h
file in an extern "C"
block to get a C interface.
Porting the implementation down to straight C would be tedious,
but straightforward.
Copyright
Copyright 1999 by Steven W. McDougall.
This code is freeware.
It may be copied/modified/redistributed without restriction.
Steven W. McDougall /
resume /
swmcd@theworld.com /
1999 May 25