summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/kv.c16
-rw-r--r--src/main.c9
2 files changed, 25 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;
+}
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..033a1d0
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,9 @@
+#include <stdio.h>
+#include <kv.h>
+
+int main() {
+ kv_t *table = kv_init(3);
+ printf("%p\n", table);
+
+ printf("%zu\n", table->capacity);
+}