Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

MemoryManagement

Collaboration diagram for MemoryManagement:


Files

file  psMemory.h
 Contains the definitions for the memory management system.

Modules

 Memory Callbacks
 Routines dealing with the creating and setting of memory management callback functions.
 Memory Tracing
 Routines dealing with memory tracing and corruption checking.
 Reference Count
 Routines dealing with the reference counting of allocated buffers.

Data Structures

struct  psMemBlock
 Book-keeping data for storage allocator. More...

Typedefs

typedef unsigned long psMemId
 typedef for memory identification numbers. Guaranteed to be some variety of integer.
typedef unsigned long psReferenceCount
 typedef for a memory block's reference count. Guaranteed to be some variety of integer.
typedef void(* psFreeFunc )(void *ptr)
 typedef for deallocator.
typedef psMemBlock psMemBlock
 Book-keeping data for storage allocator.

Functions

psPtr psAlloc (size_t size)
 Memory allocation.
void psMemSetDeallocator (psPtr ptr, psFreeFunc freeFunc)
 Set the deallocator routine.
psFreeFunc psMemGetDeallocator (const psPtr ptr)
 Get the deallocator routine.
bool psMemCheckType (psDataType type, psPtr ptr)
 Checks the deallocator to see if the pointer matches the desired datatype.
void p_psMemSetPersistent (psPtr ptr, bool value)
 Set the memory as persistent so that it is ignored when detecting memory leaks.
bool p_psMemGetPersistent (psPtr ptr)
 Get the memory's persistent flag.
psPtr psRealloc (psPtr ptr, size_t size)
 Memory re-allocation.
void psFree (psPtr ptr)
 Free memory.


Typedef Documentation

typedef void(* psFreeFunc)(void *ptr)
 

typedef for deallocator.

Definition at line 57 of file psMemory.h.

typedef struct psMemBlock psMemBlock
 

Book-keeping data for storage allocator.

N.b. sizeof(psMemBlock) must be chosen such that if ptr is a pointer returned by malloc, then ((char *)ptr + sizeof(psMemBlock)) is properly aligned for all storage types.

typedef unsigned long psMemId
 

typedef for memory identification numbers. Guaranteed to be some variety of integer.

Definition at line 51 of file psMemory.h.

typedef unsigned long psReferenceCount
 

typedef for a memory block's reference count. Guaranteed to be some variety of integer.

Definition at line 54 of file psMemory.h.


Function Documentation

bool p_psMemGetPersistent psPtr  ptr  ) 
 

Get the memory's persistent flag.

Checks if a memory block has been marked as persistent by p_psMemSetPresistent.

Memory marked as persistent is excluded from memory leak checks.

Returns:
bool true if memory is marked persistent, otherwise false.
Parameters:
ptr  the memory block to check.

void p_psMemSetPersistent psPtr  ptr,
bool  value
 

Set the memory as persistent so that it is ignored when detecting memory leaks.

Used to mark a memory block as persistent data within the library, i.e., non user-level data used to hold psLib's state or cache data. Such examples of this class of memory is psTrace's trace-levels and dynamic error codes.

Memory marked as persistent is excluded from memory leak checks.

Parameters:
ptr  the memory block to operate on
value  true if memory is persistent, otherwise false

psPtr psAlloc size_t  size  ) 
 

Memory allocation.

This operates much like malloc(), but is guaranteed to return a non-NULL value.

Returns:
psPtr pointer to the allocated buffer. This will not be NULL.
See also:
psFree
Parameters:
size  Size required

void psFree psPtr  ptr  ) 
 

Free memory.

This operates much like free().

See also:
psAlloc, psRealloc
Parameters:
ptr  Pointer to free, if NULL, function returns immediately.

bool psMemCheckType psDataType  type,
psPtr  ptr
 

Checks the deallocator to see if the pointer matches the desired datatype.

Returns:
bool: True if type matches, otherwise false.
Parameters:
type  The desired psDataType to match
ptr  The desired pointer to match

psFreeFunc psMemGetDeallocator const psPtr  ptr  ) 
 

Get the deallocator routine.

This function returns the deallocator for a memory block. A deallocator routine can optionally be assigned to a memory block to ensure that associated memory blocks also get freed, e.g., memory buffers referenced within a struct.

Returns:
psFreeFunc the routine to be called at deallocation.
Parameters:
ptr  the memory block

void psMemSetDeallocator psPtr  ptr,
psFreeFunc  freeFunc
 

Set the deallocator routine.

A deallocator routine can optionally be assigned to a memory block to ensure that associated memory blocks also get freed, e.g., memory buffers referenced within a struct.

Parameters:
ptr  the memory block to operate on
freeFunc  the function to be executed at deallocation

psPtr psRealloc psPtr  ptr,
size_t  size
 

Memory re-allocation.

This operates much like realloc(), but is guaranteed to return a non-NULL value.

Returns:
psPtr pointer to resized buffer. This will not be NULL.
See also:
psAlloc, psFree
Parameters:
ptr  Pointer to re-allocate
size  Size required


Generated on Wed Sep 14 10:43:48 2005 for Pan-STARRS Foundation Library by  doxygen 1.4.2