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

Memory Callbacks
[MemoryManagement]

Collaboration diagram for Memory Callbacks:


Detailed Description

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


Typedefs

typedef psMemId(* psMemAllocCallback )(const psMemBlock *ptr)
 prototype of a basic callback used by memory functions
typedef psMemId(* psMemFreeCallback )(const psMemBlock *ptr)
 prototype of memory free callback used by memory functions
typedef void(* psMemProblemCallback )(psMemBlock *ptr, const char *filename, unsigned int 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.
psMemAllocCallback psMemAllocCallbackSet (psMemAllocCallback 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.
psMemId psMemGetId (void)
 get next memory ID
psMemId psMemAllocCallbackSetID (psMemId id)
 set p_psMemAllocID to specific id
psMemId psMemFreeCallbackSetID (psMemId id)
 set p_psMemFreeID to id


Typedef Documentation

typedef psMemId(* psMemAllocCallback)(const psMemBlock *ptr)
 

prototype of a basic callback used by memory functions

See also:
psMemAllocCallbackSet

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 psMemId(* 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)(psMemBlock *ptr,const char *filename,unsigned int 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

psMemAllocCallback psMemAllocCallbackSet psMemAllocCallback  func  ) 
 

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

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

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

psMemId psMemAllocCallbackSetID psMemId  id  ) 
 

set p_psMemAllocID to specific id

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

Returns:
psMemId
See also:
psMemAllocCallbackSet
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

psMemId psMemFreeCallbackSetID psMemId  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:
psMemId the old p_psMemFreeID
See also:
psMemFreeCallbackSet
Parameters:
id  ID to set

psMemId psMemGetId void   ) 
 

get next memory ID

Returns:
psMemId 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 Thu Oct 13 14:33:51 2005 for Pan-STARRS Foundation Library by  doxygen 1.4.2