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

Memory Callbacks
[Memory Management Utilities]

Collaboration diagram for Memory Callbacks:


Detailed Description

Routines dealing with the creating and setting of memory management callback functions.


Typedefs

typedef psMemoryId(* psMemAllocateCallback )(const psMemBlock *ptr)
 prototype of a basic callback used by memory functions
typedef psMemoryId(* psMemFreeCallback )(const psMemBlock *ptr)
 prototype of memory free callback used by memory functions
typedef void(* psMemProblemCallback )(const psMemBlock *ptr, const char *file, psS32 lineno)
 prototype of a callback used in error conditions
typedef psPtr(* psMemExhaustedCallback )(size_t size)
 prototype of a callback function used when memory runs out

Functions

psMemProblemCallback psMemProblemCallbackSet (psMemProblemCallback func)
 Set callback for problems.
psMemExhaustedCallback psMemExhaustedCallbackSet (psMemExhaustedCallback func)
 Set callback for out-of-memory.
psMemAllocateCallback psMemAllocateCallbackSet (psMemAllocateCallback func)
 Set call back for when a particular memory block is allocated.
psMemFreeCallback psMemFreeCallbackSet (psMemFreeCallback func)
 Set call back for when a particular memory block is freed.
psMemoryId psMemGetId (void)
 get next memory ID
psMemoryId psMemAllocateCallbackSetID (psMemoryId id)
 set p_psMemAllocateID to specific id
psMemoryId psMemFreeCallbackSetID (psMemoryId id)
 set p_psMemFreeID to id


Typedef Documentation

typedef psMemoryId(* psMemAllocateCallback)(const psMemBlock *ptr)
 

prototype of a basic callback used by memory functions

See also:
psMemAllocateCallbackSet

Definition at line 86 of file psMemory.h.

typedef psPtr(* psMemExhaustedCallback)(size_t size)
 

prototype of a callback function used when memory runs out

Returns:
psPtr pointer to requested buffer of the size size_t, or NULL if memory could not be found.
See also:
psMemExhaustedCallbackSet

Definition at line 120 of file psMemory.h.

typedef psMemoryId(* psMemFreeCallback)(const psMemBlock *ptr)
 

prototype of memory free callback used by memory functions

See also:
psMemFreeCallbackSet

Definition at line 95 of file psMemory.h.

typedef void(* psMemProblemCallback)(const psMemBlock *ptr,const char *file,psS32 lineno)
 

prototype of a callback used in error conditions

This callback should not try to call psAlloc or psFree.

See also:
psMemProblemCallbackSet

Definition at line 106 of file psMemory.h.


Function Documentation

psMemAllocateCallback psMemAllocateCallbackSet psMemAllocateCallback  func  ) 
 

Set call back for when a particular memory block is allocated.

A private variable, p_psMemAllocateID, can be used to trace the allocation and freeing of specific memory blocks. If p_psMemAllocateID is set and a memory block with that ID is allocated, psMemAllocateCallback is called just before memory is returned to the calling function.

Returns:
psMemAllocateCallback old psMemAllocateCallback function
Parameters:
func  Function to run at memory allocation of specific mem block

psMemoryId psMemAllocateCallbackSetID psMemoryId  id  ) 
 

set p_psMemAllocateID to specific id

A private variable, p_psMemAllocateID, can be used to trace the allocation and freeing of specific memory blocks. If p_psMemAllocateID is set and a memory block with that ID is allocated, psMemAllocateCallback is called just before memory is returned to the calling function.

Returns:
psMemoryId
See also:
psMemAllocateCallbackSet
Parameters:
id  ID to set

psMemExhaustedCallback psMemExhaustedCallbackSet psMemExhaustedCallback  func  ) 
 

Set callback for out-of-memory.

If not enough memory is available to satisfy a request by psAlloc or psRealloc, these functions attempt to find an alternative solution by calling the psMemExhaustedCallback, a function which may be set by the programmer in appropriate circumstances, rather than immediately fail. The typical use of such a feature may be when a program needs a large chunk of memory to do an operation, but the exact size is not critical. This feature gives the programmer the opportunity to make a smaller request and try again, limiting the size of the operating buffer.

Returns:
psMemExhaustedCallback old psMemExhaustedCallback function
Parameters:
func  Function to run at memory exhaustion

psMemFreeCallback psMemFreeCallbackSet psMemFreeCallback  func  ) 
 

Set call back for when a particular memory block is freed.

A private variable, p_psMemFreeID, can be used to trace the freeing of specific memory blocks. If p_psMemFreeID is set and the memory block with the ID is about to be freed, the psMemFreeCallback callback is called just before the memory block is freed.

Returns:
psMemFreeCallback old psMemFreeCallback function
Parameters:
func  Function to run at memory free of specific mem block

psMemoryId psMemFreeCallbackSetID psMemoryId  id  ) 
 

set p_psMemFreeID to id

A private variable, p_psMemFreeID, can be used to trace the freeing of specific memory blocks. If p_psMemFreeID is set and the memory block with the ID is about to be freed, the psMemFreeCallback callback is called just before the memory block is freed.

Returns:
psMemoryId the old p_psMemFreeID
See also:
psMemFreeCallbackSet
Parameters:
id  ID to set

psMemoryId psMemGetId void   ) 
 

get next memory ID

Returns:
psMemoryId the next memory ID to be used

psMemProblemCallback psMemProblemCallbackSet psMemProblemCallback  func  ) 
 

Set callback for problems.

At various occasions, the memory manager can check the state of the memory stack. If any of these checks discover that the memory stack is corrupted, the psMemProblemCallback is called.

Returns:
psMemProblemCallback old psMemProblemCallback function
Parameters:
func  Function to run at memory problem detection


Generated on Wed Jun 15 11:01:15 2005 for Pan-STARRS Foundation Library by  doxygen 1.4.1