System memory allocator.
More...
#include <stddef.h>
#include <stdint.h>
Go to the source code of this file.
|
| void * | st_mem_alloc (size_t size, const char *file, int line) |
| | Allocate a contiguous memory region and optionally log a message on failure.
|
| |
| void | st_mem_free (void *ptr, const char *file, int line) |
| | Free a contiguous memory region and optionally log a message on failure.
|
| |
|
void | st_mem_cleanup (void) |
| | If supported, free all the memory allocated with the system allocator.
|
| |
◆ st_alloc
| #define st_alloc |
( |
|
size | ) |
st_mem_alloc((size), __FILE__, __LINE__) |
◆ st_free
| #define st_free |
( |
|
ptr | ) |
st_mem_free((ptr), __FILE__, __LINE__) |
◆ ST_NEW
| #define ST_NEW |
( |
|
... | ) |
ST__NEW(__VA_ARGS__, 1, ) |
Allocate memory for a data type.
A call ST_NEW(type, n) will alocate contiguous memory region of the length that is equal to the multiple of n and the size of type. The n argument is optional and by default it equals 1.
◆ st_mem_alloc()
| st_mem_alloc |
( |
size_t |
size, |
|
|
const char * |
file, |
|
|
int |
line |
|
) |
| |
Allocate a contiguous memory region and optionally log a message on failure.
- Parameters
-
| [in] | size | The number of bytes to allocate. |
| [in] | file | The path to the file (for logging). |
| [in] | line | The line number (for logging). |
- Returns
- The pointer to the allocated memory region.
◆ st_mem_free()
| void st_mem_free |
( |
void * |
ptr, |
|
|
const char * |
file, |
|
|
int |
line |
|
) |
| |
Free a contiguous memory region and optionally log a message on failure.
- Parameters
-
| [in] | ptr | The pointer to the memory region. |
| [in] | file | The path to the file (for logging). |
| [in] | line | The line number (for logging). |