Main Page | Modules | Data Structures | File List | Globals | Related Pages

memory.h File Reference


Detailed Description

Tracks the size of allocations made.

A wrapper for the standard memory manager that tracks the size of the allocations made using it. This requires an extra 8 bytes per allocation. You can turn this off by editing the memory.h file and commenting out the definition of DEBUGMEMORY, but this will cause some of the features of some of the research learners to fail in unpredictable ways.

Go to the source code of this file.

Defines

#define MMemMove(dst, src, bytes)   __SystemMoveMemory(dst, src, bytes)
 Wrapper for memmove that works with pointers allocated by this memory module.


Functions

void * MNewPtr (int size)
 A wrapper around Malloc that tracks the size of the allocation.

void MFreePtr (void *ptr)
 Frees the memory held by the pointer and tracks the change in the module's records.

void MSetAllocFailFunction (void(*AllocFail)(int allocationSize))
 Sets a function that is called if an allocation fails.

long MGetTotalAllocation (void)
 Returns the number of bytes that are currently allocated by the module.

void MSetActivePool (int poolID)
 Set the pool to track future memory allocations.

int MGetActivePool (void)
 Find which pool is being used to track memory.

long MGetPoolAllocation (int poolID)
 Returns the number of bytes that are currently allocated in the specified pool.

void MMovePtrToPool (void *ptr, int poolID)
 Moves the memory from one pool to another.


Define Documentation

#define MMemMove dst,
src,
bytes   )     __SystemMoveMemory(dst, src, bytes)
 

Wrapper for memmove that works with pointers allocated by this memory module.


Function Documentation

void MFreePtr void *  ptr  ) 
 

Frees the memory held by the pointer and tracks the change in the module's records.

int MGetActivePool void   ) 
 

Find which pool is being used to track memory.

The module supports up to 9 pools of memory, with id 1-9. You can get more fine grained tracking by setting the pool and using MGetPoolAllocation. There is also a special pool, with id 0, and any allocations made when that pool are set are tracked in the pool but will not show up in MGetTotalAllocation. The default pool id is 1.

long MGetPoolAllocation int  poolID  ) 
 

Returns the number of bytes that are currently allocated in the specified pool.

The module supports up to 9 pools of memory, with id 1-9. You can get more fine grained tracking by setting the pool and using MGetPoolAllocation. There is also a special pool, with id 0, and any allocations made when that pool are set are tracked in the pool but will not show up in MGetTotalAllocation. The default pool id is 1.

long MGetTotalAllocation void   ) 
 

Returns the number of bytes that are currently allocated by the module.

void MMovePtrToPool void *  ptr,
int  poolID
 

Moves the memory from one pool to another.

Changes (if needed) the tracking of the ptr so that it is now counted against the new pool instead of the pool it was allocated into.

void* MNewPtr int  size  ) 
 

A wrapper around Malloc that tracks the size of the allocation.

Make sure you use MFreePtr to free any memory allocated by this call or your program will probably crash.

void MSetActivePool int  poolID  ) 
 

Set the pool to track future memory allocations.

The module supports up to 9 pools of memory, with id 1-9. You can get more fine grained tracking by setting the pool and using MGetPoolAllocation. There is also a special pool, with id 0, and any allocations made when that pool are set are tracked in the pool but will not show up in MGetTotalAllocation. The default pool id is 1.

void MSetAllocFailFunction void(*  AllocFail)(int allocationSize)  ) 
 

Sets a function that is called if an allocation fails.

If you call this, then your AllocFail function will be called if an allocation fails. After your function returns the memory module will try the allocation agian, if the allocation fails again, the memory module returns a NULL pointer. You could use AllocFail to flush caches, or clean up the program and quit.


Generated for VFML by doxygen hosted by SourceForge.net Logo