9_hashtable_add_collision(
hashitem_t* item,
const char* key, int64_t value);
12_hashtable_find_collision(
hashitem_t* item,
const char* key);
15_hash_djb2(
const char* key);
64 if (strcmp(item->
key.
data, key) == 0) {
69 _hashtable_add_collision(item, key, value);
82 if (strcmp(item->
key.
data, key) == 0) {
87 item = _hashtable_find_collision(item, key);
97_hashtable_add_collision(
hashitem_t* item,
const char* key, int64_t value)
99 hashitem_t* collision = _hashtable_find_collision(item, key);
101 if (collision != NULL) {
102 collision->
value = value;
113 collision->
value = value;
120_hashtable_find_collision(
hashitem_t* item,
const char* key)
132_hash_djb2(
const char* key)
137 hash = (hash * 33) ^ *key++;
void dstring_init(dstring_t *string, unsigned int buffer_size)
Initializes a dynamic string (dstring).
void dstring_copy(dstring_t *string, const char *source)
Copies the content of source to the dstring.
void dstring_close(dstring_t *string)
Closes the dynamic string.
enum error_code error_code_t
Enumeration of error codes.
void hashtable_init(hashtable_t *hashtable, unsigned int size)
Initializes a hashtable.
error_code_t hashtable_get(hashtable_t *hashtable, const char *key, int64_t *value)
Get the value of the specified key inside the hashtable.
void hashtable_close(hashtable_t *hashtable)
Close the given hashtable.
void hashtable_set(hashtable_t *hashtable, const char *key, int64_t value)
Set the value of the specified key inside the hashtable.
char * data
Pointer for the raw string content (a normal C string).
struct hashitem * _collisions
List of another items with hash colliding with this.
unsigned int _collisions_size
The number of item slots allocated to _collisions memory.
bool is_set
Is true if this item has set.
int64_t value
The value of the item.
dstring_t key
The item's key.
unsigned int _collisions_length
The number of items on the _collisions list.
unsigned int _size
The number of item slots of the items allocated memory.
hashitem_t * items
List of items on the hashtable.
struct hashitem hashitem_t
An item inside a hashtable.
#define HASHTABLE_COLLISION_CHUNK_SIZE
The number of collisions items to (re)alloc when a collision occurs.
struct hashtable hashtable_t
A hashtable.