CYAML Internals
Functions
mem.h File Reference

CYAML memory allocation handling. More...

#include "cyaml/cyaml.h"
Include dependency graph for mem.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

static void cyaml__free (const cyaml_config_t *config, void *ptr)
 
static void * cyaml__realloc (const cyaml_config_t *config, void *ptr, size_t current_size, size_t new_size, bool clean)
 
static void * cyaml__alloc (const cyaml_config_t *config, size_t size, bool clean)
 
static char * cyaml__strdup (const cyaml_config_t *config, const char *str)
 

Detailed Description

CYAML memory allocation handling.

Function Documentation

◆ 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]configThe CYAML client config.
[in]sizeThe number of bytes to allocate.
[in]cleanIf 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()

static void cyaml__free ( const cyaml_config_t config,
void *  ptr 
)
inlinestatic

Helper for freeing using the client's choice of allocator routine.

Parameters
[in]configThe CYAML client config.
[in]ptrPointer 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]configThe CYAML client config.
[in]ptrThe existing allocation or NULL.
[in]current_sizeSize of the current allocation. (Only needed if clean != false).
[in]new_sizeThe number of bytes to resize allocation to.
[in]cleanOnly 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 
)
inlinestatic

Helper for string duplication using the client's choice of allocator routine.

Parameters
[in]configThe CYAML client config.
[in]strThe string to duplicate.
Returns
Pointer to new string on success, or NULL on failure.