34 }
else if (index < item->metadata.array_metadata.end_ptr) {
62 data[metadata->
end_ptr++] = pushee;
71 size_t new_allocation = metadata->
allocated == 0 ? 1 : CBOR_BUFFER_GROWTH * metadata->
allocated;
74 if (new_data == NULL) {
78 array->
data = new_data;
119 for (
size_t i = 0; i < size; i++)
132 .data = (
unsigned char *)data
struct cbor_item_t cbor_item_t
The item handle.
union cbor_item_metadata metadata
Discriminated by type.
void cbor_intermediate_decref(cbor_item_t *item)
Decreases the reference count by one, deallocating the item if needed.
bool cbor_array_replace(cbor_item_t *item, size_t index, cbor_item_t *value)
Replace item at an index.
void * _cbor_realloc_multiple(void *pointer, size_t item_size, size_t item_count)
Overflow-proof contiguous array reallocation.
void * _cbor_alloc_multiple(size_t item_size, size_t item_count)
Overflow-proof contiguous array allocation.
cbor_item_t * cbor_new_indefinite_array()
Create new indefinite array.
bool cbor_array_set(cbor_item_t *item, size_t index, cbor_item_t *value)
Set item by index.
size_t refcount
Reference count - initialize to 0.
bool cbor_array_is_definite(const cbor_item_t *item)
Is the array definite?
bool cbor_array_push(cbor_item_t *array, cbor_item_t *pushee)
Append to the end.
size_t cbor_array_size(const cbor_item_t *item)
Get the number of members.
cbor_item_t * cbor_incref(cbor_item_t *item)
Increases the reference count by one.
bool cbor_isa_array(const cbor_item_t *item)
Does the item have the appropriate major type?
cbor_item_t * cbor_new_definite_array(size_t size)
Create new definite array.
unsigned char * data
Raw data block - interpretation depends on metadata.
bool _cbor_safe_to_multiply(size_t a, size_t b)
Can a and b be multiplied without overflowing size_t?
size_t cbor_array_allocated(const cbor_item_t *item)
Get the size of the allocated storage.
cbor_item_t * cbor_array_get(const cbor_item_t *item, size_t index)
Get item by index.
bool cbor_array_is_indefinite(const cbor_item_t *item)
Is the array indefinite?
cbor_item_t ** cbor_array_handle(const cbor_item_t *item)
Get the array contents.