// Functions for getting and setting the system heaps.
void rvSetSysHeap( Rv_Sys_Heap_ID_t sysHeapID, rvHeap *heapPtr ); // associates a heap with the given system heap ID value
rvHeap* rvGetSysHeap( Rv_Sys_Heap_ID_t sysHeapID ); // retrieves the specified system heap
void rvGetAllSysHeaps( rvHeap *destSystemHeapArray[MAX_SYSTEM_HEAPS] ); // retrieves all the MAX_SYSTEM_HEAPS heap pointers into the given array
void rvSetAllSysHeaps( rvHeap *srcSystemHeapArray[MAX_SYSTEM_HEAPS] ); // associates all the MAX_SYSTEM_HEAPS heap pointers from the given array with their corresponding id value
bool rvPushHeapContainingMemory( const void* mem ); // pushes the heap containg the memory specified to the top of the arena stack, making it current - mwhitlock
void rvEnterArenaCriticalSection( ); // enters the heap arena critical section
void rvExitArenaCriticalSection( ); // exits the heap arena critical section
void rvPushSysHeap(Rv_Sys_Heap_ID_t sysHeapID); // pushes the system heap associated with the given identifier to the top of the arena stack, making it current
// Useful in situations where a heap is pushed, but a return on error or an
// exception could cause the stack to be unwound, bypassing the heap pop
// operation - mwhitlock.
class rvAutoHeapCtxt
{
bool mPushed;
public:
rvAutoHeapCtxt(void) :
mPushed(false)
{
// Should never call this.
assert(0);
}
rvAutoHeapCtxt(Rv_Sys_Heap_ID_t sysHeapID) :
mPushed(false)
{
rvPushSysHeap(sysHeapID);
mPushed = true;
}
rvAutoHeapCtxt(const void* mem) :
mPushed(false)
{
mPushed = rvPushHeapContainingMemory( mem );
}
~rvAutoHeapCtxt(void)
{
if(mPushed)
{
currentHeapArena->Pop();
}
}
};
//
// RV_PUSH_SYS_HEAP_ID()
// Push system heaps by their ID (always available to idLib, Game and executable).