API description in detail how to manage variable arrays.
More...
◆ caps_libtable_init()
| void caps_libtable_init |
( |
void |
| ) |
|
Initialize the library prior use
Mostly sets up its internally used libraries.
- Note
- This function can be called multiple times.
◆ caps_table_init()
Initialize a variable table
- Parameters
-
| [in,out] | tbl | The table to init |
| [in] | td | The element description of this variable table |
◆ caps_table_cleanup()
Free resources occupied by the given variable table
- Parameters
-
| [in,out] | tbl | The table to release |
- Attention
- This does not include the data this table contains. You need to free it on demand prior cleanup the table itself.
◆ caps_table_element_ensure_free()
Ensure at least one element in the table is still free to use
- Parameters
-
| [in,out] | tbl | The table to check |
In the case the current table is exhausted, it will increase the table size by the value of the caps_table_desc::increment member to ensure new free elements. Due to this, the managed table base will change.
- Postcondition
- After a call to caps_table_element_ensure_free() you must call caps_table_base_get() again, if you want to work on the table.
- Note
- In case of memory failure, this function does not return!
◆ caps_table_base_get()
Retrieve the table's base pointer
- Parameters
-
| [in] | tbl | The table to get its base pointer from |
- Return values
-
| table | Base address of the managed table |
| NULL | If the table is uninitialized and thus, empty. |
To ensure at least an element at index zero exists, you need to call caps_table_element_ensure_free() first.
- Postcondition
- After adding new elements, the base pointer must be retreived again!
◆ caps_table_element_count_get()
| size_t caps_table_element_count_get |
( |
const struct caps_var_table * |
tbl | ) |
|
Retrieve the table's already used elements count
- Parameters
-
| [in] | tbl | The table to get the elements count from |
- Return values
-
| number | Elements count |
| 0 | If the table is empty. |
◆ caps_table_element_count_increment()
| size_t caps_table_element_count_increment |
( |
struct caps_var_table * |
tbl | ) |
|
Increment the table's used elements count
- Parameters
-
| [in] | tbl | The table to increment the used elements count |
- Returns
- New element's index