Objective Systems, Inc.  

Rtmem
[C Runtime Common Functions]


Defines

#define memAlloc(pctxt, nbytes)   memHeapAlloc(&(pctxt)->pTypeMemHeap,nbytes)
 Allocate memory.
#define memAllocZ(pctxt, nbytes)   memHeapAllocZ(&(pctxt)->pTypeMemHeap,nbytes)
 Allocate and zero memory.
#define memAllocType(pctxt, ctype)   (ctype*)memHeapAlloc(&(pctxt)->pTypeMemHeap,sizeof(ctype))
 Allocate type.
#define memAllocTypeZ(pctxt, ctype)   (ctype*)memHeapAllocZ(&(pctxt)->pTypeMemHeap,sizeof(ctype))
 Allocate type and zero memory.
#define memRealloc(pctxt, mem_p, nbytes)   memHeapRealloc(&(pctxt)->pTypeMemHeap, (void*)mem_p, nbytes)
 Reallocate memory.
#define memFreePtr(pctxt, mem_p)
 Free memory pointer.
#define memFree(pctxt)   memHeapFreeAll(&(pctxt)->pTypeMemHeap)
 Free memory associated with a context.
#define memReset(pctxt)   memHeapReset(&(pctxt)->pTypeMemHeap)
 Reset memory associated with a context.
#define OSCDECL

Typedefs

typedef void *OSCDECL * OSMallocFunc (size_t size)
typedef void *OSCDECL * OSReallocFunc (void *ptr, size_t size)

Functions

typedef void (OSCDECL *OSFreeFunc)(void *ptr)
EXTERN void memHeapAddRef (void **ppvMemHeap)
EXTERN void * memHeapAlloc (void **ppvMemHeap, int nbytes)
EXTERN void * memHeapAllocZ (void **ppvMemHeap, int nbytes)
EXTERN int memHeapCheckPtr (void **ppvMemHeap, void *mem_p)
EXTERN int memHeapCreate (void **ppvMemHeap)
EXTERN void memHeapFreeAll (void **ppvMemHeap)
EXTERN void memHeapFreePtr (void **ppvMemHeap, void *mem_p)
EXTERN void * memHeapRealloc (void **ppvMemHeap, void *mem_p, int nbytes_)
EXTERN void memHeapRelease (void **ppvMemHeap)
EXTERN void memHeapReset (void **ppvMemHeap)
EXTERN void * memHeapMarkSaved (void **ppvMemHeap, const void *mem_p, ASN1BOOL saved)
EXTERN void memHeapSetProperty (void **ppvMemHeap, ASN1UINT propId, void *pProp)
EXTERN void memSetAllocFuncs (OSMallocFunc malloc_func, OSReallocFunc realloc_func, OSFreeFunc free_func)
 This function sets the pointers to standard allocation functions.
EXTERN void memFreeOpenSeqExt (OOCTXT *pctxt, DList *pElemList)
EXTERN void memHeapSetFlags (OOCTXT *pctxt, ASN1UINT flags)
EXTERN void memHeapClearFlags (OOCTXT *pctxt, ASN1UINT flags)
EXTERN void memHeapSetDefBlkSize (OOCTXT *pctxt, ASN1UINT blkSize)
 This function sets the pointer to standard allocation functions.
EXTERN ASN1UINT memHeapGetDefBlkSize (OOCTXT *pctxt)
 This function returns the actual granularity of memory blocks.

Define Documentation

#define memAlloc ( pctxt,
nbytes   )     memHeapAlloc(&(pctxt)->pTypeMemHeap,nbytes)

Allocate memory.

This macro allocates the given number of bytes. It is similar to the C malloc run-time function.

Parameters:
pctxt - Pointer to a context block
nbytes - Number of bytes of memory to allocate
Returns:
- Void pointer to allocated memory or NULL if insufficient memory was available to fulfill the request.

Definition at line 811 of file ooasn1.h.

#define memAllocZ ( pctxt,
nbytes   )     memHeapAllocZ(&(pctxt)->pTypeMemHeap,nbytes)

Allocate and zero memory.

This macro allocates the given number of bytes and then initializes the memory block to zero.

Parameters:
pctxt - Pointer to a context block
nbytes - Number of bytes of memory to allocate
Returns:
- Void pointer to allocated memory or NULL if insufficient memory was available to fulfill the request.

Definition at line 823 of file ooasn1.h.

#define memAllocType ( pctxt,
ctype   )     (ctype*)memHeapAlloc(&(pctxt)->pTypeMemHeap,sizeof(ctype))

Allocate type.

This macro allocates memory to hold a variable of the given type.

Parameters:
pctxt - Pointer to a context block
ctype - Name of C typedef
Returns:
- Pointer to allocated memory or NULL if insufficient memory was available to fulfill the request.

Definition at line 835 of file ooasn1.h.

#define memAllocTypeZ ( pctxt,
ctype   )     (ctype*)memHeapAllocZ(&(pctxt)->pTypeMemHeap,sizeof(ctype))

Allocate type and zero memory.

This macro allocates memory to hold a variable of the given type and initializes the allocated memory to zero.

Parameters:
pctxt - Pointer to a context block
ctype - Name of C typedef
Returns:
- Pointer to allocated memory or NULL if insufficient memory was available to fulfill the request.

Definition at line 847 of file ooasn1.h.

#define memRealloc ( pctxt,
mem_p,
nbytes   )     memHeapRealloc(&(pctxt)->pTypeMemHeap, (void*)mem_p, nbytes)

Reallocate memory.

This macro reallocates a memory block (either expands or contracts) to the given number of bytes. It is similar to the C realloc run-time function.

Parameters:
pctxt - Pointer to a context block
mem_p - Pointer to memory block to reallocate. This must have been allocated using the memHeapAlloc macro or the memHeapAlloc function.
nbytes - Number of bytes of memory to which the block is to be resized.
Returns:
- Void pointer to allocated memory or NULL if insufficient memory was available to fulfill the request. This may be the same as the pmem pointer that was passed in if the block did not need to be relocated.

Definition at line 864 of file ooasn1.h.

#define memFreePtr ( pctxt,
mem_p   ) 

Value:

if (memHeapCheckPtr (&(pctxt)->pTypeMemHeap, (void*)mem_p)) \
memHeapFreePtr(&(pctxt)->pTypeMemHeap, (void*)mem_p)
Free memory pointer.

This macro frees memory at the given pointer. The memory must have been allocated using the memHeapAlloc (or similar) macros or the mem memory allocation macros. This macro is similar to the C free function.

Parameters:
pctxt - Pointer to a context block
mem_p - Pointer to memory block to free. This must have been allocated using the memHeapAlloc or memAlloc macro or the memHeapAlloc function.

Definition at line 878 of file ooasn1.h.

#define memFree ( pctxt   )     memHeapFreeAll(&(pctxt)->pTypeMemHeap)

Free memory associated with a context.

This macro frees all memory held within a context. This is all memory allocated using the memHeapAlloc (and similar macros) and the mem memory allocation functions using the given context variable.

Parameters:
pctxt - Pointer to a context block

Definition at line 890 of file ooasn1.h.

#define memReset ( pctxt   )     memHeapReset(&(pctxt)->pTypeMemHeap)

Reset memory associated with a context.

This macro resets all memory held within a context. This is all memory allocated using the memHeapAlloc (and similar macros) and the mem memory allocation functions using the given context variable.

The difference between this and the ASN1MEMFREE macro is that the memory blocks held within the context are not actually freed. Internal pointers are reset so the existing blocks can be reused. This can provide a performace improvement for repetitive tasks such as decoding messages in a loop.

Parameters:
pctxt - Pointer to a context block

Definition at line 907 of file ooasn1.h.


Function Documentation

EXTERN void memSetAllocFuncs ( OSMallocFunc  malloc_func,
OSReallocFunc  realloc_func,
OSFreeFunc  free_func 
)

This function sets the pointers to standard allocation functions.

These functions are used to allocate/reallocate/free the memory blocks. By default, standard C functions - 'malloc', 'realloc' and 'free' - are used. But if some platforms do not support these functions (or some other reasons exist) they can be overloaded. The functions being overloaded should have the same prototypes as standard ones.

Parameters:
malloc_func Pointer to the memory allocation function ('malloc' by default).
realloc_func Pointer to the memory reallocation function ('realloc' by default).
free_func Pointer to the memory deallocation function ('free' by default).

EXTERN void memHeapSetDefBlkSize ( OOCTXT pctxt,
ASN1UINT  blkSize 
)

This function sets the pointer to standard allocation functions.

These functions are used to allocate/reallocate/free the memory blocks. By default, standard C functions - malloc, realloc, and free - are used. But if some platforms do not support these functions or some other reasons exist) they can be overloaded. The functions being overloaded should have the same prototypes as standard ones.

Parameters:
pctxt Pointer to a context block.
blkSize The currently used minimum size and the granularity of memory blocks.

EXTERN ASN1UINT memHeapGetDefBlkSize ( OOCTXT pctxt  ) 

This function returns the actual granularity of memory blocks.

Parameters:
pctxt Pointer to a context block.


This file was last modified on 28 May 2010.
Objective Open H.323 Stack, 0.9.1