29 }
else if (index < item->metadata.array_metadata.end_ptr) {
54 data[metadata->
end_ptr++] = pushee;
63 size_t new_allocation = metadata->
allocated == 0
65 : CBOR_BUFFER_GROWTH * metadata->
allocated;
69 if (new_data == NULL) {
73 array->
data = new_data;
103 for (
size_t i = 0; i < size; i++) {
113 .data = (
unsigned char*)data};
_cbor_malloc_t _cbor_malloc
bool cbor_array_is_indefinite(const cbor_item_t *item)
Is the array indefinite?
bool cbor_array_set(cbor_item_t *item, size_t index, cbor_item_t *value)
Set item by index.
bool cbor_array_replace(cbor_item_t *item, size_t index, cbor_item_t *value)
Replace item at an index.
size_t cbor_array_size(const cbor_item_t *item)
Get the number of members.
size_t cbor_array_allocated(const cbor_item_t *item)
Get the size of the allocated storage.
cbor_item_t ** cbor_array_handle(const cbor_item_t *item)
Get the array contents.
bool cbor_array_push(cbor_item_t *array, cbor_item_t *pushee)
Append to the end.
bool cbor_array_is_definite(const cbor_item_t *item)
Is the array definite?
cbor_item_t * cbor_new_definite_array(size_t size)
Create new definite array.
cbor_item_t * cbor_array_get(const cbor_item_t *item, size_t index)
Get item by index.
cbor_item_t * cbor_new_indefinite_array(void)
Create new indefinite array.
void cbor_intermediate_decref(cbor_item_t *item)
Decreases the item's reference count by one, deallocating the item if needed.
bool cbor_isa_array(const cbor_item_t *item)
Does the item have the appropriate major type?
cbor_item_t * cbor_incref(cbor_item_t *item)
Increases the item's reference count by one.
#define _CBOR_DEPENDENT_NOTNULL(cbor_item, pointer)
#define _CBOR_NOTNULL(cbor_item)
@ CBOR_TYPE_ARRAY
4 - arrays
@ _CBOR_METADATA_DEFINITE
@ _CBOR_METADATA_INDEFINITE
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.
bool _cbor_safe_to_multiply(size_t a, size_t b)
Can a and b be multiplied without overflowing size_t?
unsigned char * data
Raw data block - interpretation depends on metadata.
union cbor_item_metadata metadata
Discriminated by type.