libcbor
0.5.0
libcbor is a C library for parsing and generating CBOR, the general-purpose schema-less binary data format.
|
#include <stdlib.h>
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <assert.h>
#include "data.h"
#include "cbor/configuration.h"
Go to the source code of this file.
Macros | |
#define | CBOR_RESTRICT_POINTER CBOR_RESTRICT_SPECIFIER |
#define | CBOR_VERSION TO_STR(CBOR_MAJOR_VERSION) "." TO_STR(CBOR_MINOR_VERSION) "." TO_STR(CBOR_PATCH_VERSION) |
#define | CBOR_HEX_VERSION ((CBOR_MAJOR_VERSION << 16) | (CBOR_MINOR_VERSION << 8) | CBOR_PATCH_VERSION) |
#define | debug_print(fmt, ...) do {} while (0) |
#define | TO_STR_(x) #x |
#define | TO_STR(x) TO_STR_(x) /* enables proper double expansion */ |
#define | _CBOR_MALLOC _cbor_malloc |
#define | _CBOR_REALLOC _cbor_realloc |
#define | _CBOR_FREE _cbor_free |
Typedefs | |
typedef void *(* | _cbor_malloc_t) (size_t) |
typedef void *(* | _cbor_realloc_t) (void *, size_t) |
typedef void(* | _cbor_free_t) (void *) |
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... | |
cbor_type | cbor_typeof (const cbor_item_t *item) |
Get the type of the item. More... | |
bool | cbor_isa_uint (const cbor_item_t *item) |
Does the item have the appropriate major type? More... | |
bool | cbor_isa_negint (const cbor_item_t *item) |
Does the item have the appropriate major type? More... | |
bool | cbor_isa_bytestring (const cbor_item_t *item) |
Does the item have the appropriate major type? More... | |
bool | cbor_isa_string (const cbor_item_t *item) |
Does the item have the appropriate major type? More... | |
bool | cbor_isa_array (const cbor_item_t *item) |
Does the item have the appropriate major type? More... | |
bool | cbor_isa_map (const cbor_item_t *item) |
Does the item have the appropriate major type? More... | |
bool | cbor_isa_tag (const cbor_item_t *item) |
Does the item have the appropriate major type? More... | |
bool | cbor_isa_float_ctrl (const cbor_item_t *item) |
Does the item have the appropriate major type? More... | |
bool | cbor_is_int (const cbor_item_t *item) |
Is the item an integer, either positive or negative? More... | |
bool | cbor_is_float (const cbor_item_t *item) |
Is the item an a floating point number? More... | |
bool | cbor_is_bool (const cbor_item_t *item) |
Is the item an a boolean? More... | |
bool | cbor_is_null (const cbor_item_t *item) |
Does this item represent null More... | |
bool | cbor_is_undef (const cbor_item_t *item) |
Does this item represent undefined More... | |
cbor_item_t * | cbor_incref (cbor_item_t *item) |
Increases the reference count by one. More... | |
void | cbor_decref (cbor_item_t **item) |
Decreases the reference count by one, deallocating the item if needed. More... | |
void | cbor_intermediate_decref (cbor_item_t *item) |
Decreases the reference count by one, deallocating the item if needed. More... | |
size_t | cbor_refcount (const cbor_item_t *item) |
Get the reference count. More... | |
cbor_item_t * | cbor_move (cbor_item_t *item) |
Provides CPP-like move construct. More... | |
Variables | |
_cbor_malloc_t | _cbor_malloc |
_cbor_realloc_t | _cbor_realloc |
_cbor_free_t | _cbor_free |
#define _CBOR_FREE _cbor_free |
#define _CBOR_MALLOC _cbor_malloc |
#define _CBOR_REALLOC _cbor_realloc |
#define CBOR_HEX_VERSION ((CBOR_MAJOR_VERSION << 16) | (CBOR_MINOR_VERSION << 8) | CBOR_PATCH_VERSION) |
#define TO_STR | ( | x | ) | TO_STR_(x) /* enables proper double expansion */ |
void cbor_decref | ( | cbor_item_t ** | item | ) |
cbor_item_t* cbor_incref | ( | cbor_item_t * | item | ) |
void cbor_intermediate_decref | ( | cbor_item_t * | item | ) |
Decreases the reference count by one, deallocating the item if needed.
Convenience wrapper for cbor_decref when its set-to-null behavior is not needed
item[take] | the item |
bool cbor_is_bool | ( | const cbor_item_t * | item | ) |
bool cbor_is_float | ( | const cbor_item_t * | item | ) |
bool cbor_is_int | ( | const cbor_item_t * | item | ) |
bool cbor_is_null | ( | const cbor_item_t * | item | ) |
bool cbor_is_undef | ( | const cbor_item_t * | item | ) |
bool cbor_isa_array | ( | const cbor_item_t * | item | ) |
Does the item have the appropriate major type?
item[borrow] | the item |
bool cbor_isa_bytestring | ( | const cbor_item_t * | item | ) |
Does the item have the appropriate major type?
item[borrow] | the item |
bool cbor_isa_float_ctrl | ( | const cbor_item_t * | item | ) |
Does the item have the appropriate major type?
item[borrow] | the item |
bool cbor_isa_map | ( | const cbor_item_t * | item | ) |
Does the item have the appropriate major type?
item[borrow] | the item |
bool cbor_isa_negint | ( | const cbor_item_t * | item | ) |
Does the item have the appropriate major type?
item[borrow] | the item |
bool cbor_isa_string | ( | const cbor_item_t * | item | ) |
Does the item have the appropriate major type?
item[borrow] | the item |
bool cbor_isa_tag | ( | const cbor_item_t * | item | ) |
Does the item have the appropriate major type?
item[borrow] | the item |
bool cbor_isa_uint | ( | const cbor_item_t * | item | ) |
Does the item have the appropriate major type?
item[borrow] | the item |
cbor_item_t* cbor_move | ( | cbor_item_t * | item | ) |
Provides CPP-like move construct.
Decreases the reference count by one, but does not deallocate the item even if its refcount reaches zero. This is useful for passing intermediate values to functions that increase reference count. Should only be used with functions that incref
their arguments.
embed:rst:leading-asterisk * .. warning:: If the item is moved without correctly increasing the reference count afterwards, the memory will be leaked. *
item[take] | the item |
size_t cbor_refcount | ( | const cbor_item_t * | item | ) |
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 *
custom_malloc | malloc implementation |
custom_realloc | realloc implementation |
custom_free | free implementation |
Definition at line 14 of file allocators.c.
cbor_type cbor_typeof | ( | const cbor_item_t * | item | ) |
_cbor_free_t _cbor_free |
Definition at line 12 of file allocators.c.
_cbor_malloc_t _cbor_malloc |
Definition at line 10 of file allocators.c.
_cbor_realloc_t _cbor_realloc |
Definition at line 11 of file allocators.c.