diff options
| author | Ibrahim Muftee <ibrahim@muftee.net> | 2026-08-02 23:08:35 -0500 |
|---|---|---|
| committer | Ibrahim Muftee <ibrahim@muftee.net> | 2026-08-02 23:09:17 -0500 |
| commit | e70d4061e7bd9c376dd4d92df91ed0cef022b426 (patch) | |
| tree | 4959f5a6a76de7773b330085e86d50570b583f97 /src | |
Diffstat (limited to 'src')
| -rw-r--r-- | src/kv.c | 16 | ||||
| -rw-r--r-- | src/main.c | 9 |
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); +} |
