Memory Allocation Macros and FunctionsMemory 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. |
Special algorithms are used for allocation and deallocation of memory to improve the run-time performance.
#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)
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.
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 |
#define ALLOC_ASN1ELEM | ( | pctxt, | |||
type | ) | (type*) memHeapAllocZ (&(pctxt)->pTypeMemHeap, sizeof(type)) |
#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.
pctxt | - Pointer to a context block | |
nbytes | - Number of bytes of memory to allocate |
#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.
pctxt | - Pointer to a context block |
#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.
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. |