32 .metadata = {.map_metadata = {
39 if (item->
data == NULL) {
54 .metadata = {.map_metadata = {
87 size_t new_allocation = metadata->
allocated == 0 ? 1 : CBOR_BUFFER_GROWTH * metadata->
allocated;
91 if (new_data == NULL) {
95 item->
data = new_data;
struct cbor_item_t cbor_item_t
The item handle.
size_t cbor_map_allocated(const cbor_item_t *item)
Get the size of the allocated storage.
union cbor_item_metadata metadata
Discriminated by type.
void * _cbor_realloc_multiple(void *pointer, size_t item_size, size_t item_count)
Overflow-proof contiguous array reallocation.
size_t cbor_map_size(const cbor_item_t *item)
Get the number of pairs.
bool _cbor_map_add_key(cbor_item_t *item, cbor_item_t *key)
Add a key to the map.
void * _cbor_alloc_multiple(size_t item_size, size_t item_count)
Overflow-proof contiguous array allocation.
bool cbor_map_is_indefinite(const cbor_item_t *item)
Is this map indefinite?
Simple pair of items for use in maps.
size_t refcount
Reference count - initialize to 0.
cbor_item_t * cbor_incref(cbor_item_t *item)
Increases the reference count by one.
bool cbor_isa_map(const cbor_item_t *item)
Does the item have the appropriate major type?
bool cbor_map_is_definite(const cbor_item_t *item)
Is this map definite?
bool _cbor_map_add_value(cbor_item_t *item, cbor_item_t *value)
Add a value to the map.
unsigned char * data
Raw data block - interpretation depends on metadata.
cbor_item_t * cbor_new_indefinite_map()
Create a new indefinite map.
bool cbor_map_add(cbor_item_t *item, struct cbor_pair pair)
Add a pair to the map.
bool _cbor_safe_to_multiply(size_t a, size_t b)
Can a and b be multiplied without overflowing size_t?
struct cbor_pair * cbor_map_handle(const cbor_item_t *item)
Get the pairs storage.
cbor_item_t * cbor_new_definite_map(size_t size)
Create a new definite map.