Go to the source code of this file.
|
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) |
|
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.
- Parameters
-
[in] | table | |
[in] | key | |
[in] | element | |
- Returns
- HTP_OK on success, HTP_ERROR on failure.
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.
- Parameters
-
[in] | table | |
[in] | key | |
[in] | element | |
- Returns
- HTP_OK on success, HTP_ERROR on failure.
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.
- Parameters
-
[in] | table | |
[in] | key | |
[in] | element | |
- Returns
- HTP_OK on success, HTP_ERROR on failure.
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.
- Parameters
-
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.
- Parameters
-
Create a new table structure. The table will grow automatically as needed, but you are required to provide a starting size.
- Parameters
-
[in] | size | The starting size. |
- Returns
- Newly created table instance, or NULL on failure.
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.
- Parameters
-
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.
- Parameters
-
Retrieve the first element that matches the given bstr key.
- Parameters
-
- Returns
- Matched element, or NULL if no elements match the 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.
- Parameters
-
- Returns
- Matched element, or NULL if no elements match the key.
void* htp_table_get_index |
( |
const htp_table_t * |
table, |
|
|
size_t |
idx, |
|
|
bstr ** |
key |
|
) |
| |
Retrieve key and element at the given index.
- Parameters
-
[in] | table | |
[in] | idx | |
[in,out] | key | Pointer in which the key will be returned. Can be NULL. |
- Returns
- HTP_OK on success, HTP_ERROR on failure.
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.
- Parameters
-
[in] | table | |
[in] | key | |
[in] | key_len | |
- Returns
- Matched element, or NULL if no elements match the key.
Return the size of the table.
- Parameters
-
- Returns
- table size