Objective Systems, Inc.  

Memory Allocation Macros and Functions
[C Runtime Common Functions]

Memory allocation functions and macros handle memory management for the ASN1C run-time. More...

Defines

#define ALLOC_ASN1ARRAY(pctxt, pseqof, type)
 Allocate a dynamic array.
#define ALLOC_ASN1ELEM(pctxt, type)   (type*) memHeapAllocZ (&(pctxt)->pTypeMemHeap, sizeof(type))
 Allocate and zero an ASN.1 element.
#define ASN1MALLOC(pctxt, nbytes)   memHeapAlloc(&(pctxt)->pTypeMemHeap, nbytes)
 Allocate memory.
#define ASN1MEMFREE(pctxt)   memHeapFreeAll(&(pctxt)->pTypeMemHeap)
 Free memory associated with a context.
#define ASN1MEMFREEPTR(pctxt, pmem)   memHeapFreePtr(&(pctxt)->pTypeMemHeap, (void*)pmem)
 Free memory pointer.

Detailed Description

Memory allocation functions and macros handle memory management for the ASN1C run-time.

Special algorithms are used for allocation and deallocation of memory to improve the run-time performance.


Define Documentation

#define ALLOC_ASN1ARRAY ( pctxt,
pseqof,
type   ) 

Value:

do {\
if (sizeof(type)*(pseqof)->n < (pseqof)->n) return ASN_E_NOMEM; \
if (((pseqof)->elem = (type*) memHeapAlloc \
(&(pctxt)->pTypeMemHeap, sizeof(type)*(pseqof)->n)) == 0) return ASN_E_NOMEM; \
} while (0)
Allocate a dynamic array.

This macro allocates a dynamic array of records of the given type. This version of the macro will return the ASN_E_NOMEM error status if the memory request cannot be fulfilled.

Parameters:
pctxt - Pointer to a context block
pseqof - Pointer to a generated SEQUENCE OF array structure. The n member variable must be set to the number of records to allocate.
type - Data type of an array record

Definition at line 445 of file ooasn1.h.

#define ALLOC_ASN1ELEM ( pctxt,
type   )     (type*) memHeapAllocZ (&(pctxt)->pTypeMemHeap, sizeof(type))

Allocate and zero an ASN.1 element.

This macro allocates and zeros a single element of the given type.

Parameters:
pctxt - Pointer to a context block
type - Data type of record to allocate

Definition at line 458 of file ooasn1.h.

#define ASN1MALLOC ( 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 471 of file ooasn1.h.

#define ASN1MEMFREE ( 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 ASN1MALLOC (and similar macros) and the mem memory allocation functions using the given context variable.

Parameters:
pctxt - Pointer to a context block

Definition at line 482 of file ooasn1.h.

#define ASN1MEMFREEPTR ( pctxt,
pmem   )     memHeapFreePtr(&(pctxt)->pTypeMemHeap, (void*)pmem)

Free memory pointer.

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

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

Definition at line 496 of file ooasn1.h.


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