|
maug
Quick and dirty C mini-augmentation library.
|
A vector of uniformly-sized objects, stored contiguously. More...
#include <mdata.h>
Data Fields | |
| uint8_t | flags |
| MAUG_MHANDLE | data_h |
| Handle for allocated items (unlocked). | |
| uint8_t * | data_bytes |
| Handle for allocated items (locked). | |
| size_t | ct_max |
| Maximum number of items currently allocated for. | |
| size_t | ct |
| Maximum number of items actually used. | |
| size_t | ct_step |
| Number of items added when more space is needed. | |
| size_t | item_sz |
| Size, in bytes, of each item. More... | |
| ssize_t | locks |
| Lock count, if MDATA_VECTOR_FLAG_REFCOUNT is enabled. | |
Related Functions | |
(Note that these are not member functions.) | |
| #define | MDATA_VECTOR_FLAG_REFCOUNT 0x01 |
| Flag for MDATA_VECTOR::flags indicating that vector may uses reference counting for locking. More... | |
| #define | MDATA_VECTOR_INIT_STEP_SZ 10 |
| Default initial value for MDATA_VECTOR::ct_step. | |
| ssize_t | mdata_vector_append (struct MDATA_VECTOR *v, const void *item, size_t item_sz) |
| Append an item to the specified vector. More... | |
| MERROR_RETVAL | mdata_vector_remove (struct MDATA_VECTOR *v, size_t idx) |
| Remove item at the given index, shifting subsequent items up by 1. More... | |
| void * | mdata_vector_get_void (const struct MDATA_VECTOR *v, size_t idx) |
| Get a generic pointer to an item in the MDATA_VECTOR. More... | |
| #define | mdata_vector_lock(v) |
| Lock the vector. This should be done when items from the vector are actively being referenced, so the system is not allowed to move the vector's data allocation block. More... | |
| #define | mdata_vector_unlock(v) |
| Unlock the vector so items may be added and removed. More... | |
| #define | mdata_vector_ct(v) ((v)->ct) |
| Number of items of MDATA_VECTOR::item_sz bytes actively stored in this vector. More... | |
| #define | mdata_vector_sz(v) (((v)->ct_max) * ((v)->item_sz)) |
| Number of bytes of heap memory occupied by this vector. | |
| #define | mdata_vector_fill(v, ct_new, sz) |
| Allocate and mark the new slots as active. More... | |
A vector of uniformly-sized objects, stored contiguously.
May be initialized with mdata_vector_alloc() before use, but mdata_vector_append() will attempt to do this automatically.
|
related |
Number of items of MDATA_VECTOR::item_sz bytes actively stored in this vector.
|
related |
Allocate and mark the new slots as active.
|
related |
Flag for MDATA_VECTOR::flags indicating that vector may uses reference counting for locking.
Such a mobile may be locked multiple times, but then must be unlocked an equal number of times to unlock.
|
related |
Lock the vector. This should be done when items from the vector are actively being referenced, so the system is not allowed to move the vector's data allocation block.
|
related |
Unlock the vector so items may be added and removed.
| size_t MDATA_VECTOR::item_sz |
Size, in bytes, of each item.