hashmap/src/node.c

24 lines
537 B
C

#include <node.h>
#include <stdlib.h>
struct node *new_node(const char *key, const void *value) {
struct node *new = calloc(1, sizeof(struct node));
new->next = NULL;
new->prev = NULL;
new->key = key;
new->value = value;
return new;
}
struct node *insert_node(struct node *entry, const char *key, const void *value) {
struct node *insert = new_node(key, value);
insert->prev = entry;
if(entry != NULL) {
insert->next = entry->next;
entry->next = insert;
}
return insert;
}