14#define CDICT_ERROR_CAN_NOT_ALLOCATE_MEMORY 1
15#define ERROR_ITEM_NOT_FOUND 2
16#define ERROR_NULL_VALUE_FOR_KEY 3
17#define ERROR_DICT_POINTER_IS_NULL 4
19#define TABLE_SIZE 0x100001
46 void *(*copy_func)(
void*);
void * cdict_get_nocase(cdict_ctx *ctx, char *key)
get a value from the dictionary by providing the key (case-insensitive key)
int cdict_has_key_nocase(cdict_ctx *ctx, char *key)
Checks if the key exists in the dictionary (case-insensitive comparison)
void cdict_free_keylist(cdict_keylist *klst, int clone_keys)
This function free the keylist structure returned by cdict_keys()
void cdict_free(cdict_ctx *ctx)
Frees the memory allocated for the dictionary.
int cdict_has_key(cdict_ctx *ctx, char *key)
Checks if the key exists in the dictionary.
int cdict_set_nocase(cdict_ctx *ctx, char *key, void *value)
Sets the new value for a given key (make key lower case first).
cdict_ctx * cdict_init(void(*free_func)(void *), void *(*copy_func)(void *))
Initializes the Dictionary in the memory.
void cdict_remove(cdict_ctx *ctx, char *key)
Removes a key-value pair from the dictionary.
int cdict_set(cdict_ctx *ctx, char *key, void *value)
Sets the new value for a given key.
void * cdict_get(cdict_ctx *ctx, char *key)
cdict_keylist * cdict_keys(cdict_ctx *ctx, int clone_keys)
Get the list of keys from the dictionary.
PNODE table
Pointer to an array of NODE structure.
int err
Possible Error code.
WORD * hash_table
Pointer to the hash table for hashing.
char * errmsg
Description of the possible error.
void(* free_func)(void *)
a pointer to the free function provided by user
char * key
key for finding matches. Key is a null-terminated string
void * value
Value to store. value is a pointer to void so it can be any type.
struct _NODE * next
A pointer points to the next node in case of collision.