CAPS Universe documentation  1.0.4
All you need to know to be successful
Data Structures | Functions

API description in detail how to manage variable arrays. More...

Data Structures

struct  caps_table_desc
 
struct  caps_var_table
 Variable table. More...
 

Functions

void caps_libtable_init (void)
 
void caps_table_init (struct caps_var_table *tbl, const struct caps_table_desc *td)
 
void caps_table_cleanup (struct caps_var_table *tbl)
 
void caps_table_element_ensure_free (struct caps_var_table *tbl)
 
void * caps_table_base_get (const struct caps_var_table *tbl)
 
size_t caps_table_element_count_get (const struct caps_var_table *tbl)
 
size_t caps_table_element_count_increment (struct caps_var_table *tbl)
 

Detailed Description

Function Documentation

◆ 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()

void caps_table_init ( struct caps_var_table tbl,
const struct caps_table_desc td 
)

Initialize a variable table

Parameters
[in,out]tblThe table to init
[in]tdThe element description of this variable table

◆ caps_table_cleanup()

void caps_table_cleanup ( struct caps_var_table tbl)

Free resources occupied by the given variable table

Parameters
[in,out]tblThe 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()

void caps_table_element_ensure_free ( struct caps_var_table tbl)

Ensure at least one element in the table is still free to use

Parameters
[in,out]tblThe 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()

void * caps_table_base_get ( const struct caps_var_table tbl)

Retrieve the table's base pointer

Parameters
[in]tblThe table to get its base pointer from
Return values
tableBase address of the managed table
NULLIf 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]tblThe table to get the elements count from
Return values
numberElements count
0If 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]tblThe table to increment the used elements count
Returns
New element's index