CYAML memory allocation handling.
More...
Go to the source code of this file.
CYAML memory allocation handling.
◆ cyaml__alloc()
static void* cyaml__alloc |
( |
const cyaml_config_t * |
config, |
|
|
size_t |
size, |
|
|
bool |
clean |
|
) |
| |
|
inlinestatic |
Helper for new allocations using the client's choice of allocator routine.
- Parameters
-
[in] | config | The CYAML client config. |
[in] | size | The number of bytes to allocate. |
[in] | clean | If false , the memory is uninitialised, if true , the memory is initialised to zero. |
- Returns
- Pointer to allocation on success, or
NULL
on failure.
◆ cyaml__free()
Helper for freeing using the client's choice of allocator routine.
- Parameters
-
[in] | config | The CYAML client config. |
[in] | ptr | Pointer to allocation to free. |
◆ cyaml__realloc()
static void* cyaml__realloc |
( |
const cyaml_config_t * |
config, |
|
|
void * |
ptr, |
|
|
size_t |
current_size, |
|
|
size_t |
new_size, |
|
|
bool |
clean |
|
) |
| |
|
inlinestatic |
Helper for new allocations using the client's choice of allocator routine.
- Note
- On failure, any existing allocation is still owned by the caller, and they are responsible for freeing it.
- Parameters
-
[in] | config | The CYAML client config. |
[in] | ptr | The existing allocation or NULL. |
[in] | current_size | Size of the current allocation. (Only needed if clean != false ). |
[in] | new_size | The number of bytes to resize allocation to. |
[in] | clean | Only applies if new_size > current_size . If false , the new memory is uninitialised, if true , the new memory is initialised to zero. |
- Returns
- Pointer to allocation on success, or
NULL
on failure.
◆ cyaml__strdup()
static char* cyaml__strdup |
( |
const cyaml_config_t * |
config, |
|
|
const char * |
str, |
|
|
size_t * |
len_out |
|
) |
| |
|
inlinestatic |
Helper for string duplication using the client's choice of allocator routine.
- Parameters
-
[in] | config | The CYAML client config. |
[in] | str | The string to duplicate. |
[in] | len_out | If non-NULL, updated to length of string on success. |
- Returns
- Pointer to new string on success, or
NULL
on failure.