libcbor  0.5.0
libcbor is a C library for parsing and generating CBOR, the general-purpose schema-less binary data format.
Functions | Variables
allocators.c File Reference
#include "cbor/common.h"

Go to the source code of this file.

Functions

void cbor_set_allocs (_cbor_malloc_t custom_malloc, _cbor_realloc_t custom_realloc, _cbor_free_t custom_free)
 Sets the memory management routines to use. More...
 

Variables

_cbor_malloc_t _cbor_malloc = malloc
 
_cbor_realloc_t _cbor_realloc = realloc
 
_cbor_free_t _cbor_free = free
 

Function Documentation

§ cbor_set_allocs()

void cbor_set_allocs ( _cbor_malloc_t  custom_malloc,
_cbor_realloc_t  custom_realloc,
_cbor_free_t  custom_free 
)

Sets the memory management routines to use.

Only available when CBOR_CUSTOM_ALLOC is truthy

embed:rst:leading-asterisk
* .. warning:: This function modifies the global state and should therefore be used accordingly. Changing the memory handlers while allocated items exist will result in a ``free``/``malloc`` mismatch. This function is not thread safe with respect to both itself and all the other *libcbor* functions that work with the heap.
* .. note:: `realloc` implementation must correctly support `NULL` reallocation
* 
Parameters
custom_mallocmalloc implementation
custom_reallocrealloc implementation
custom_freefree implementation

Definition at line 14 of file allocators.c.

Variable Documentation

§ _cbor_free

_cbor_free_t _cbor_free = free

Definition at line 12 of file allocators.c.

§ _cbor_malloc

_cbor_malloc_t _cbor_malloc = malloc

Definition at line 10 of file allocators.c.

§ _cbor_realloc

_cbor_realloc_t _cbor_realloc = realloc

Definition at line 11 of file allocators.c.