Dillo v3.1.1-99-gf3103cc4
|
A simple ADT for Key-Data pairs. More...
#include "klist.h"
Go to the source code of this file.
Functions | |
static int | Klist_node_by_key_cmp (const void *Node, const void *key) |
Compare function for searching data by its key. | |
static int | Klist_node_by_node_cmp (const void *Node1, const void *Node2) |
Compare function for searching data by node. | |
void * | a_Klist_get_data (Klist_t *Klist, int Key) |
Return the data pointer for a given Key (or NULL if not found) | |
int | a_Klist_insert (Klist_t **Klist, void *Data) |
Insert a data pointer and return a key for it. | |
void | a_Klist_remove (Klist_t *Klist, int Key) |
Remove data by Key. | |
int | a_Klist_length (Klist_t *Klist) |
Return the number of elements in the Klist. | |
void | a_Klist_free (Klist_t **KlistPtr) |
Free a Klist. | |
A simple ADT for Key-Data pairs.
NOTE: this ADT is not perfect. The possibility of holding a Key, after its data has been removed, long enough for the key-counter to reset and reuse the same key is very low, but EXISTS. So, the responsibility remains with the caller.
Definition in file klist.c.
void a_Klist_free | ( | Klist_t ** | KlistPtr | ) |
Free a Klist.
Definition at line 110 of file klist.c.
References dFree(), dList_free(), dList_length(), dList_nth_data(), dList_remove_fast(), and Klist_t::List.
Referenced by a_Http_freeall().
void * a_Klist_get_data | ( | Klist_t * | Klist, |
int | Key | ||
) |
Return the data pointer for a given Key (or NULL if not found)
Definition at line 43 of file klist.c.
References dList_find_sorted(), INT2VOIDP, Klist_node_by_key_cmp(), and Klist_t::List.
Referenced by a_Http_ccc(), a_Http_connect_done(), a_Klist_insert(), a_Tls_mbedtls_connection(), a_Tls_openssl_connection(), Dpi_conn_valid(), Http_connect_socket(), Http_connect_socket_cb(), Http_connect_tls(), Http_dns_cb(), Http_get(), Http_socket_free(), Http_socket_reuse(), IO_get(), Tls_close_by_key(), Tls_close_by_key(), Tls_connect(), and Tls_handshake().
int a_Klist_insert | ( | Klist_t ** | Klist, |
void * | Data | ||
) |
Insert a data pointer and return a key for it.
Definition at line 56 of file klist.c.
References a_Klist_get_data(), KlistNode_t::Data, dList_insert_sorted(), dList_new(), dNew, KlistNode_t::Key, and Klist_node_by_node_cmp().
Referenced by Dpi_conn_new(), Http_sock_new(), IO_ins(), Tls_conn_new(), and Tls_make_conn_key().
int a_Klist_length | ( | Klist_t * | Klist | ) |
Return the number of elements in the Klist.
Definition at line 102 of file klist.c.
References dList_length(), and Klist_t::List.
void a_Klist_remove | ( | Klist_t * | Klist, |
int | Key | ||
) |
Remove data by Key.
Definition at line 86 of file klist.c.
References Klist_t::Clean, dFree(), dList_find_sorted(), dList_length(), dList_remove(), INT2VOIDP, Klist_node_by_key_cmp(), and Klist_t::List.
Referenced by Dpi_conn_free(), Http_socket_free(), IO_del(), Tls_close_by_key(), and Tls_close_by_key().
|
static |
Compare function for searching data by its key.
Definition at line 27 of file klist.c.
References VOIDP2INT.
Referenced by a_Klist_get_data(), and a_Klist_remove().
|
static |
Compare function for searching data by node.
Definition at line 35 of file klist.c.
Referenced by a_Klist_insert().