HTP
0.5
|
Functions | |
htp_status_t | htp_table_add (htp_table_t *table, const bstr *key, const void *element) |
htp_status_t | htp_table_addn (htp_table_t *table, const bstr *key, const void *element) |
htp_status_t | htp_table_addk (htp_table_t *table, const bstr *key, const void *element) |
void | htp_table_clear (htp_table_t *table) |
void | htp_table_clear_ex (htp_table_t *table) |
htp_table_t * | htp_table_create (size_t size) |
void | htp_table_destroy (htp_table_t *table) |
void | htp_table_destroy_ex (htp_table_t *table) |
void * | htp_table_get (const htp_table_t *table, const bstr *key) |
void * | htp_table_get_c (const htp_table_t *table, const char *ckey) |
void * | htp_table_get_index (const htp_table_t *table, size_t idx, bstr **key) |
void * | htp_table_get_mem (const htp_table_t *table, const void *key, size_t key_len) |
size_t | htp_table_size (const htp_table_t *table) |
htp_status_t htp_table_add | ( | htp_table_t * | table, |
const bstr * | key, | ||
const void * | element | ||
) |
Add a new element to the table. The key will be copied, and the copy managed by the table. The table keeps a pointer to the element. It is the callers responsibility to ensure the pointer remains valid.
[in] | table | |
[in] | key | |
[in] | element |
htp_status_t htp_table_addk | ( | htp_table_t * | table, |
const bstr * | key, | ||
const void * | element | ||
) |
Add a new element to the table. The key provided will be only referenced and the caller remains responsible to keep it alive until after the table is destroyed. The table keeps a pointer to the element. It is the callers responsibility to ensure the pointer remains valid.
[in] | table | |
[in] | key | |
[in] | element |
htp_status_t htp_table_addn | ( | htp_table_t * | table, |
const bstr * | key, | ||
const void * | element | ||
) |
Add a new element to the table. The key provided will be adopted and managed by the table. You should not keep a copy of the pointer to the key unless you're certain that the table will live longer that the copy. The table keeps a pointer to the element. It is the callers responsibility to ensure the pointer remains valid.
[in] | table | |
[in] | key | |
[in] | element |
void htp_table_clear | ( | htp_table_t * | table | ) |
Remove all elements from the table. This function handles keys according to the active allocation strategy. If the elements need freeing, you need to free them before invoking this function.
[in] | table |
void htp_table_clear_ex | ( | htp_table_t * | table | ) |
Remove all elements from the table without freeing any of the keys, even if the table is using an allocation strategy where keys belong to it. This function is useful if all the keys have been adopted by some other structure.
[in] | table |
htp_table_t* htp_table_create | ( | size_t | size | ) |
Create a new table structure. The table will grow automatically as needed, but you are required to provide a starting size.
[in] | size | The starting size. |
void htp_table_destroy | ( | htp_table_t * | table | ) |
Destroy a table. This function handles the keys according to the active allocation strategy. If the elements need freeing, you need to free them before invoking this function. After the table has been destroyed, the pointer is set to NULL.
[in] | table |
void htp_table_destroy_ex | ( | htp_table_t * | table | ) |
Destroy the given table, but don't free the keys. even if they are managed by the table. Use this method when the responsibility for the keys has been transferred elsewhere. After the table has been destroyed, the pointer is set to NULL.
[in] | table |
void* htp_table_get | ( | const htp_table_t * | table, |
const bstr * | key | ||
) |
Retrieve the first element that matches the given bstr key.
[in] | table | |
[in] | key |
void* htp_table_get_c | ( | const htp_table_t * | table, |
const char * | ckey | ||
) |
Retrieve the first element that matches the given NUL-terminated key.
[in] | table | |
[in] | ckey |
void* htp_table_get_index | ( | const htp_table_t * | table, |
size_t | idx, | ||
bstr ** | key | ||
) |
Retrieve key and element at the given index.
[in] | table | |
[in] | idx | |
[in,out] | key | Pointer in which the key will be returned. Can be NULL. |
void* htp_table_get_mem | ( | const htp_table_t * | table, |
const void * | key, | ||
size_t | key_len | ||
) |
Retrieve table key defined by the provided pointer and length.
[in] | table | |
[in] | key | |
[in] | key_len |
size_t htp_table_size | ( | const htp_table_t * | table | ) |
Return the size of the table.
[in] | table |