summaryrefslogtreecommitdiff
path: root/src/kv.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/kv.c')
-rw-r--r--src/kv.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/kv.c b/src/kv.c
new file mode 100644
index 0000000..d936cf0
--- /dev/null
+++ b/src/kv.c
@@ -0,0 +1,16 @@
+#include <kv.h>
+
+kv_t *kv_init(size_t capacity) {
+ if (capacity == 0) return NULL;
+
+ kv_t *table = malloc(sizeof(kv_t));
+ if (table == NULL) return NULL;
+
+ table->capacity = capacity;
+ table->count = 0;
+
+ table->entries = calloc(capacity, sizeof(kv_entry_t));
+ if (table->entries == NULL) return NULL;
+
+ return table;
+}