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

Memory Management Utilities
[System Utilities]

Collaboration diagram for Memory Management Utilities:


Detailed Description

This is the generic memory management system put inbetween the user's high level code and the OS-level memory allocation routines.

This system adds such features as callback routines for memory error events, tracing capabilities, and reference counting.


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 psU64 psMemoryId
 typedef for memory identification numbers. Guaranteed to be some variety of integer.
typedef psU64 psReferenceCount
 typedef for a memory block's reference count. Guaranteed to be some variety of integer.
typedef void(* psFreeFcn )(psPtr 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, psFreeFcn freeFcn)
 Set the deallocator routine.
psFreeFcn psMemGetDeallocator (psPtr ptr)
 Get the deallocator routine.
void p_psMemSetPersistent (psPtr ptr, psBool value)
 Set the memory as persistent so that it is ignored when detecting memory leaks.
psBool 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(* psFreeFcn)(psPtr 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 psU64 psMemoryId
 

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

Definition at line 51 of file psMemory.h.

typedef psU64 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

psBool 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:
psBool true if memory is marked persistent, otherwise false.
Parameters:
ptr  the memory block to check.

void p_psMemSetPersistent psPtr  ptr,
psBool  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.

psFreeFcn psMemGetDeallocator 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:
psFreeFcn the routine to be called at deallocation.
Parameters:
ptr  the memory block

void psMemSetDeallocator psPtr  ptr,
psFreeFcn  freeFcn
 

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
freeFcn  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 Jun 15 11:01:14 2005 for Pan-STARRS Foundation Library by  doxygen 1.4.1