Memory allocator.
More...
#include <stddef.h>
Go to the source code of this file.
◆ hat_allocator_realloc_t
| typedef void *(* hat_allocator_realloc_t) (hat_allocator_t *a, size_t size, void *old) |
Custom allocator implementation function.
- Parameters
-
| [in] | a | allocator instance |
| [in] | size | new memory block size |
| [in] | old | previous memory block |
- Returns
- new memory block
Function should implement memory allocator which reallocates previously allocated memory pointed by old to newly return memory of size size. If old is NULL, then implementation allocates new memory block without resizing/copying previous. If size is set to 0, memory referenced by old is fried and NULL is returned.
◆ hat_allocator_t
◆ hat_allocator_alloc()
Allocate new memory block.
- Parameters
-
| [in] | a | allocator instance |
| [in] | size | new memory block size |
- Returns
- new memory block
If memory could not be allocated, NULL is returned.
◆ hat_allocator_free()
Free memory block.
- Parameters
-
| [in] | a | allocator instance |
| [in] | old | existing memory block |
◆ hat_allocator_realloc()
| static void * hat_allocator_realloc |
( |
hat_allocator_t * |
a, |
|
|
size_t |
size, |
|
|
void * |
old |
|
) |
| |
|
inlinestatic |
Reallocate existing memory block.
- Parameters
-
| [in] | a | allocator instance |
| [in] | size | new memory block size |
| [in] | old | existing memory block |
- Returns
- new memory block
If memory could not be reallocated, NULL is returned.