Main Page | Modules | Files | Functions | Code Elements | Data Structures | Deprecated

Memory
[Integration Tool Kit]

Functions


Function Documentation

BASE_UTILS_API void* MEM_alloc ( int  n_bytes  ) 

Allocates a block on n_bytes bytes of memory.

Returns:
On success, a pointer to the allocated block of memory is returned. If n_bytes is zero or any error occurrs then NULL is returned.
Parameters:
n_bytes  (I) number of bytes to be allocated.

BASE_UTILS_API void* MEM_crealloc ( void *  ptr,
int  n_items,
int  item_size 
)

Reallocate memory for an array and copy existing data. Works like MEM_realloc but this one is for an array and initializes extra space with zeroes.

Returns:
Pointer to the new storage.
Parameters:
ptr  (I) Pointer to start of array to be reallocated.
n_items  (I) New number of elements in the array.
item_size  (I) New size, in bytes, for a single array element.

BASE_UTILS_API void MEM_free ( void *  ptr  ) 

Frees the specified memory block. The input pointer is expected to be a valid pointer allocated via relevant MEM_ API. If ptr is NULL then no operation is performed.

Parameters:
ptr  (I) Pointer to the block to be freed.

BASE_UTILS_API void* MEM_realloc ( void *  ptr,
int  n_bytes 
)

Reallocate memory and copy existing contents. Allocates a new memory block of input size and copies contents of existing memory block. Contents of extra memory in new block are undefined.

If the input pointer is NULL, normal allocation is done. If n_bytes is zero, existing storage is freed and NULL is returned. If n_bytes is less than current size of the memory block, the first n_bytes are copied.

Returns:
Pointer to new memory block.
Parameters:
ptr  (I) Pointer to a memory block to be reallocated.
n_bytes  (I) Number of bytes to be allocated to the new block.

BASE_UTILS_API char* MEM_string_copy ( const char *  str  ) 

Make a copy of a NULL terminated string.

Returns:
Pointer to the copy of the input string.
Parameters:
str  (I) NULL terminated string to be copied.