Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CP_Heap Class Reference

Class to handle management of a MacOS Heap.

Inheritance diagram for CP_Heap:

CP_DefaultHeap List of all members.

Public Member Functions

Constructor / Destructor
 CP_Heap ()
 Constructor.
 ~CP_Heap ()
 Destructor.

Static Public Attributes

static NewFunc gNewFunc = NULL
static DeleteFunc gDeleteFunc = NULL

Protected Attributes

CP_S_MemoryBlockfFirstBlock
SInt32 fBlockCount
SInt32 fLeakCount
SInt32 fCurrentBytes
SInt32 fHighwaterMark
SInt32 fDebugOverhead
bool fDontDeleteBlocks

Static Protected Attributes

static CP_HeapgInstance = NULL

Private Member Functions

Recording
void FillBlock (void *returnPtr, UInt16 inBlockSize)
void DumpOneLeak (const void *inPtr, CP_File &inFile)
Constructor / Destructor
 CP_Heap (const CP_Heap &inHeap)
operators
CP_Heapoperator= (const CP_Heap &inHeap)

Constructor & Destructor Documentation

CP_Heap::CP_Heap  ) 
 

Constructor.

Exceptions:
none 

CP_Heap::~CP_Heap  ) 
 

Destructor.

Exceptions:
none 

CP_Heap::CP_Heap const CP_Heap inHeap  )  [private]
 


Member Function Documentation

CP_Heap * CP_Heap::Instance  )  [static]
 

Returns the single instance of this class.

Exceptions:
none 
Returns:
CP_Heap * Returns the single instance of this class.

void * CP_Heap::Allocate UInt32  inActualBytes,
bool  isArray,
const char *  inFunction,
const char *  inFile,
int  inLine
 

Allocates a block of memory. If CP_Debug_RecordMemoryAllocations is defined, then extra memory recording / debugging information is added to the allocated block.

Parameters:
inActualBytes Number of bytes to allocate. This does not included the bytes needed for debugging which will be added to the number of bytes actually allocated if the flag CP_Debug_RecordMemoryAllocations is defined.
isArray Flag to indicate if this is an array, as opposed to any other type of allocation.
inFunction The function that called this method.
inFile The file where the function that called this method is.
inLine Line in the file that called this method to allocate memory.
Exceptions:
none 
Returns:
void * Returns a pointer to the 1st byte of the data memory block. This is where you will access the allocated memory, and is past any extra debugging added to the beginning of the block.

void CP_Heap::Deallocate void *  inPtr,
bool  isArray
 

Deallocate a block of memory.

Parameters:
inPtr Pointer to the memory block to be removed.
isArray Not used.
Exceptions:
none 
Returns:
void

SInt32 CP_Heap::GetCurrentBytes  )  const
 

Returns the current number of bytes allocated.

Exceptions:
none 
Returns:
SInt32 Current number of allocated bytes.

SInt32 CP_Heap::GetHighwaterMark  )  const
 

Returns the highest number of bytes allocated.

Exceptions:
none 
Returns:
SInt32 Highest number of allocated bytes.

SInt32 CP_Heap::GetDebugOverhead  )  const
 

Returns the number of bytes used for debugging purposes.

Exceptions:
none 
Returns:
SInt32 Number of bytes used for debugging purposes.

SInt32 CP_Heap::GetLeakCount  )  const
 

Returns the number of blocks currently marked as leaks.

Exceptions:
none 
Returns:
SInt32 Number of blocks currently marked as leaks.

void CP_Heap::TurnOnDoubleDeleteDetection bool  inTurnOn = true  ) 
 

Double delete detection. Note: When double delete detection is turn on, the allocated block is only marked as deleted, but not actually deleted from memory so memory useage may dramatically increase.

Parameters:
inTurnOn If true, turn on double delete detection.
Exceptions:
none 
Returns:
void

bool CP_Heap::GetDoubleDeleteDetectionStatus  ) 
 

Returns the state of the double delete detection flag.

Exceptions:
none 
Returns:
bool Current state of the double delete detection flag. If true, then double delete detection is on.

static void* CP_Heap::operator new size_t  inSize  )  [static]
 

void CP_Heap::operator delete void *  inPtr  )  [static]
 

Deallocate memory for this object.

Parameters:
inPtr Pointer to the block of memory to deallocate.
Exceptions:
none 
Returns:
void

void CP_Heap::DumpAllAllocations CP_File outFile  ) 
 

Dump the heap memory recording results.

Parameters:
outFile The CP_File we are writing the information to.
Exceptions:
none 
Returns:
void

void CP_Heap::DumpSessionAllocations CP_File outFile,
SInt16  inSessionIndex
 

Dump allocated memory blocks in the current session.

Parameters:
outFile The CP_File we are writing the information to.
inSessionIndex Index the session we are working with.
Exceptions:
none 
Returns:
void

UInt16 CP_Heap::CountSessionLeaks SInt16  inSessionIndex  ) 
 

Returns a count of the number of leaks in the passed in session index.

Parameters:
inSessionIndex Index the session to count leaks in.
Exceptions:
none 
Returns:
void

void CP_Heap::MarkAllBlocksNonLeaks  ) 
 

Mark all of our recorded blocks as non leaks.

Exceptions:
none 
Returns:
void

void CP_Heap::ValidateBlock const void *  inPtr  )  const
 

Validate a single allocation within our heap.

Parameters:
inPtr Pointer to the block of memory to validate.
Exceptions:
none 
Returns:
void

void CP_Heap::ValidateHeap  )  const
 

Validate the heap.

Exceptions:
none 
Returns:
void

void CP_Heap::AddDebugInfo CP_S_MemoryBlock inBlock,
UInt32  inActualBytes,
bool  isArray,
const char *  inFunction,
const char *  inFile,
int  inLine
[protected]
 

Add our debugging info to the allocated memory block.

Parameters:
inBlock The allocated memory block to add the debugging information to.
inActualBytes Number of bytes to allocate. This does not included the bytes needed for debugging which will be added to the number of bytes actually allocated if the flag CP_Debug_RecordMemoryAllocations is defined.
isArray Flag to indicate if this is an array, as opposed to any other type of allocation.
inFunction The function that called this method.
inFile The file where the function that called this method is.
inLine Line in the file that called this method to allocate memory.
Exceptions:
none 
Returns:
void

void CP_Heap::FillBlock void *  returnPtr,
UInt16  inBlockSize
[private]
 

Fill our allocated block with garbage values.

Parameters:
returnPtr The memory block.
inBlockSize The size of the allocated memory block.
Exceptions:
none 
Returns:
void

void CP_Heap::DumpOneLeak const void *  inPtr,
CP_File outFile
[private]
 

Writes the information about a single leak to the passed in file.

Parameters:
inPtr The leaking memory block to write the information for.
outFile The CP_Fiel we are writing the information to.
Exceptions:
none 
Returns:
void

CP_Heap& CP_Heap::operator= const CP_Heap inHeap  )  [private]
 


Member Data Documentation

CP_Heap * CP_Heap::gInstance = NULL [static, protected]
 

CP_S_MemoryBlock* CP_Heap::fFirstBlock [protected]
 

Points to the single instance of ourselves.

SInt32 CP_Heap::fBlockCount [protected]
 

SInt32 CP_Heap::fLeakCount [protected]
 

SInt32 CP_Heap::fCurrentBytes [protected]
 

SInt32 CP_Heap::fHighwaterMark [protected]
 

SInt32 CP_Heap::fDebugOverhead [protected]
 

bool CP_Heap::fDontDeleteBlocks [protected]
 

NewFunc CP_Heap::gNewFunc = NULL [static]
 

Flag to indicate if we delete blocks, or just mark them for double delete detection.

DeleteFunc CP_Heap::gDeleteFunc = NULL [static]
 

Pointer to the function used to allocate memory.


The documentation for this class was generated from the following files:
Generated on Tue Sep 20 20:21:48 2005 for CPLAT_MacOS by  doxygen 1.4.0