C++ struct code
tmyStruct * myStruct
tmyStruct * myStruct = (tmyStruct*)...
typdef unsigned int MYTYPE
C struct code converted from C++
struct tmyStruct * myStruct
struct tmyStruct * myStruct = (struct tmyStruct*)..
#define MYTYPE unsigned int
This is a basic heap. It has no optimization function written for it, but one may appear on the link someday. It stores allocation information inside its self. Making it a nice and compact type.
http://mcguire.sytes.net:6080/hfmos/Sou ... ource.html
This is a slightly advanced heap used for shared data between threads or different processes. It supports garbage collection, and consolidation of free space. It however, uses the basic heap to store allocation information. So you need the basic one too when using this one.
http://mcguire.sytes.net:6080/hfmos/Sou ... ource.html
Note: The advanced heap uses the basic heap to seperate allocation information from data. To prevent heap corruption, however, when sharing data corruption is still possible.
The advanced heap also uses a different system for allocation, and deallocation. It takes a group ID, that you select or randomly generate for each allocation. Instead of calling the deallocation function with a pointer, you give it a group ID and it deallocates all allocations made using that ID previously.
Also, using the advanced heap. You can use a macro like this.
Code: Select all
RELEASE(myPointer);
Code: Select all
LOCK(myPointer);
UNLOCK(myPointer);
Also, instead of using the RELEASE, or you can use the CLAIM macros and time arguments. It would be better to setup the optimize function to be called on a interval, via a seperate thread or timer. This allows the allocation functions to use a time argument. Every time the optimize is called, its time argument has been incremented. Once a group has expired it is automaticly garbage collected unless entries have been CLAIMed. Each entry/allocation with-in the group can be calimed 252 times. This could be nice for threads sharing data, but could also be a disaster in waiting. It could be used for a single thread, when it only needs select items from the heap, but does not want to waste time RELEASEing them.
If a RELEASE is called using the time feature, it will over-ride the time and perform a deallocation on the next optimize run.
If those pages do not work, because you're browser is superannuated or non-orthodox you will just have to download the zipped source (with-out line numbers). You did not need those anyway.
This code is free to use. I do not reserve any rights to this material.