CYAML Internals
Loading...
Searching...
No Matches
Macros | Functions
mem.c File Reference

CYAML memory allocation handling. More...

#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include "mem.h"
Include dependency graph for mem.c:

Macros

#define CYAML_UNUSED(_x)   ((void)(_x))
 

Functions

void * cyaml_mem (void *ctx, void *ptr, size_t size)
 

Detailed Description

CYAML memory allocation handling.

Macro Definition Documentation

◆ CYAML_UNUSED

#define CYAML_UNUSED (   _x)    ((void)(_x))

Macro to squash unused variable compiler warnings.

Function Documentation

◆ cyaml_mem()

void * cyaml_mem ( void *  ctx,
void *  ptr,
size_t  size 
)

CYAML default memory allocation / freeing function.

This is used when clients don't supply their own. It is exposed to enable clients to use the same allocator as libcyaml used internally to allocate/free memory when they have not provided their own allocation function.

Parameters
[in]ctxAllocation context, unused.
[in]ptrExisting allocation to resize, or NULL.
[in]sizeThe new size for the allocation.
Note
When size == 0 this frees ptr.
Returns
If size == 0, returns NULL. If size > 0, returns NULL on failure, and any existing allocation is left untouched, or return non-NULL as the new allocation on success, and the original pointer becomes invalid.