Hitmap 1.3
|
Hitmap functions to allocate memory. More...
Go to the source code of this file.
Macros | |
#define | hit_vmalloc(ptr, size) |
#define | hit_malloc(ptr, type, nmemb) |
#define | hit_calloc(ptr, type, nmemb) |
#define | hit_realloc(ptr, type, nmemb) |
#define | hit_free(ptr) |
Hitmap functions to allocate memory.
This is a set of macro-functions that allocate memory and check the result. They print an error message if the allocate routine fails. This is an interface for Hitmap developers.
These macros include a cast of the result pointers for compatibility with C++. In C langauge the cast is not needed because the stdlib malloc function should return a void pointer.
Definition in file hit_allocP.h.
#define hit_calloc | ( | ptr, | |
type, | |||
nmemb | |||
) |
Allocate and initialize to zero an array of elements of a given type.
It allocates a memory block of nmemb elements of the chosen type. It initializes the elements using the calloc(3) function.
[out] | ptr | Pointer to the allocated memory. |
[in] | type | Type of the elements of the array. |
[in] | nmemb | Number of elements to allocate. |
Definition at line 114 of file hit_allocP.h.
#define hit_free | ( | ptr | ) |
Free a previous allocated block of memory.
This function frees a block of memory previously allocated and pointed by ptr.
[in,out] | ptr | Pointer to the allocated memory. |
Definition at line 152 of file hit_allocP.h.
#define hit_malloc | ( | ptr, | |
type, | |||
nmemb | |||
) |
Allocate an array of elements of a given type.
It allocates a memory block of nmemb elements of the chosen type. It does not initialize the elements to a any predefined value.
[out] | ptr | Pointer to the allocated memory. |
[in] | type | Type of the elements of the array. |
[in] | nmemb | Number of elements to allocate. |
Definition at line 93 of file hit_allocP.h.
#define hit_realloc | ( | ptr, | |
type, | |||
nmemb | |||
) |
Change the number of elements of an array.
It changes the number of elements of an allocated array of a given type, using the reallocate(3) function. The size change may imply a reallocation of the whole array.
[out] | ptr | Pointer to the reallocated memory. |
[in] | type | Type of the elements of the array. |
[in] | nmemb | New number of elements in the array. |
Definition at line 134 of file hit_allocP.h.
#define hit_vmalloc | ( | ptr, | |
size | |||
) |
Allocate memory.
It allocates a memory block of size bytes, without a specific type.
[out] | ptr | Pointer to the allocated memory. |
[in] | size | Total size of the allocated memory. |
Definition at line 72 of file hit_allocP.h.