#include "arrays.h"
#include <string.h>
#include "internal/memory_utils.h"
Go to the source code of this file.
◆ cbor_array_allocated()
size_t cbor_array_allocated |
( |
const cbor_item_t * | item | ) |
|
Get the size of the allocated storage.
- Parameters
-
- Returns
- The size of the allocated storage (number of items)
Definition at line 17 of file arrays.c.
◆ cbor_array_get()
Get item by index.
- Parameters
-
item | An array |
index | The index (zero-based) |
- Returns
- Reference to the item, or
NULL
in case of boundary violation.
Increases the reference count of the underlying item. The returned reference must be released using cbor_decref.
Definition at line 22 of file arrays.c.
◆ cbor_array_handle()
Get the array contents.
The items may be reordered and modified as long as references remain consistent.
- Parameters
-
- Returns
- An array of cbor_item_t pointers of size cbor_array_size.
Definition at line 92 of file arrays.c.
◆ cbor_array_is_definite()
bool cbor_array_is_definite |
( |
const cbor_item_t * | item | ) |
|
Is the array definite?
- Parameters
-
- Returns
- Is the array definite?
Definition at line 82 of file arrays.c.
◆ cbor_array_is_indefinite()
bool cbor_array_is_indefinite |
( |
const cbor_item_t * | item | ) |
|
Is the array indefinite?
- Parameters
-
- Returns
- Is the array indefinite?
Definition at line 87 of file arrays.c.
◆ cbor_array_push()
Append to the end.
For indefinite items, storage may be reallocated. For definite items, only the preallocated capacity is available.
- Parameters
-
array | An array |
pushee | The item to push. Its reference count will be increased by one. |
- Returns
true
on success, false
on failure
Definition at line 44 of file arrays.c.
◆ cbor_array_replace()
Replace item at an index.
The reference to the item being replaced will be released using cbor_decref.
- Parameters
-
item | An array |
value | The item to assign. Its reference count will be increased by one. |
index | The index (zero-based) |
- Returns
- true on success, false on allocation failure.
Definition at line 36 of file arrays.c.
◆ cbor_array_set()
Set item by index.
If the index is out of bounds, the array is not modified and false is returned. Creating arrays with holes is not possible.
- Parameters
-
item | An array |
value | The item to assign |
index | The index (zero-based) |
- Returns
true
on success, false
on allocation failure.
Definition at line 26 of file arrays.c.
◆ cbor_array_size()
Get the number of members.
- Parameters
-
- Returns
- The number of members
Definition at line 12 of file arrays.c.
◆ cbor_new_definite_array()
Create new definite array.
- Parameters
-
size | Number of slots to preallocate |
- Returns
- Reference to the new array item. The item's reference count is initialized to one.
-
NULL
if memory allocation fails
Definition at line 97 of file arrays.c.
◆ cbor_new_indefinite_array()
Create new indefinite array.
- Returns
- Reference to the new array item. The item's reference count is initialized to one.
-
NULL
if memory allocation fails
Definition at line 118 of file arrays.c.