Functions for reading and writing array elements.
More...
|
DA_DEF void * | da_get (da_array arr, int index) |
| Gets a pointer to an element at the specified index.
|
|
DA_DEF void * | da_data (da_array arr) |
| Gets direct pointer to the underlying data array.
|
|
DA_DEF void | da_set (da_array arr, int index, const void *element) |
| Sets the value of an element at the specified index.
|
|
Functions for reading and writing array elements.
◆ da_data()
Gets direct pointer to the underlying data array.
- Parameters
-
arr | Array to access (must not be NULL) |
- Returns
- Pointer to raw data array (like stb_ds.h style)
- Note
- Enables direct indexing: ((int*)da_data(arr))[i]
-
Pointer is valid until array is modified or released
-
No bounds checking - use with care
data[0] = 42;
data[1] = 99;
DA_DEF void * da_data(da_array arr)
Gets direct pointer to the underlying data array.
Definition dynamic_array.h:1562
◆ da_get()
DA_DEF void * da_get |
( |
da_array |
arr, |
|
|
int |
index |
|
) |
| |
Gets a pointer to an element at the specified index.
- Parameters
-
arr | Array to access (must not be NULL) |
index | Element index (must be >= 0 and < length) |
- Returns
- Pointer to element at index
- Note
- Asserts on out-of-bounds access
-
Returned pointer is valid until array is modified or released
int* ptr = (
int*)
da_get(arr, 0);
*ptr = 42;
DA_DEF void * da_get(da_array arr, int index)
Gets a pointer to an element at the specified index.
Definition dynamic_array.h:1556
◆ da_set()
DA_DEF void da_set |
( |
da_array |
arr, |
|
|
int |
index, |
|
|
const void * |
element |
|
) |
| |
Sets the value of an element at the specified index.
- Parameters
-
arr | Array to modify (must not be NULL) |
index | Element index (must be >= 0 and < length) |
element | Pointer to element data to copy (must not be NULL) |
- Note
- Asserts on out-of-bounds access or NULL parameters
-
Copies element_size bytes from element pointer
int value = 42;
DA_DEF void da_set(da_array arr, int index, const void *element)
Sets the value of an element at the specified index.
Definition dynamic_array.h:1567