Tinyhash
This is a library containing multiple C implementations of hashmap.
Loading...
Searching...
No Matches
entry.c
Go to the documentation of this file.
1#include "entry.h"
2
11 th_sc_entry_t *entry = malloc(sizeof(th_sc_entry_t));
12
13 if (entry == NULL) {
14 return NULL;
15 }
16
17 entry->key = *key;
18 entry->value = value;
19 entry->previous = NULL;
20 entry->next = NULL;
21
22 return entry;
23}
24
26 th_sc_entry_t *entry = th_sc_entry_new(key, value);
27
28 if (entry == NULL) {
29 return false;
30 }
31
32 if (*root != NULL) {
33 (*root)->previous = entry;
34 }
35
36 entry->next = *root;
37 *root = entry;
38
39 return true;
40}
bool th_sc_entry_add(th_sc_entry_t **root, th_key_t *key, th_any_t value)
Add an a separate chaining entry to the beginning of a linked list. Return true on success.
Definition entry.c:25
static th_sc_entry_t * th_sc_entry_new(th_key_t *key, th_any_t value)
Allocate then initialize a new entry.
Definition entry.c:10
Represent an entry key.
Definition key.h:14
Represents a separate chaining entry.
Definition entry.h:15
struct th_sc_entry_s * previous
Definition entry.h:18
th_any_t value
Definition entry.h:17
th_key_t key
Definition entry.h:16
struct th_sc_entry_s * next
Definition entry.h:19
void * th_any_t
Represent any type of data.
Definition types.h:8