Files
kvtable/src/main.c
T

40 lines
829 B
C

#include <stdio.h>
#include <kv.h>
int main(void)
{
kv_t *table = kv_init(1024);
printf("%p\n", table);
printf("%ld\n", table->capacity);
kv_put(table, "hello", "world");
kv_put(table, "hello", "people");
kv_put(table, "goodbye", "world");
// for (int i = 0; i < table->capacity; ++i)
// {
// if (table->entries[i].key)
// {
// printf("[%d] %s: %s\n", i, table->entries[i].key, table->entries[i].val);
// }
// }
char *val = kv_get(table, "hello");
char *val2 = kv_get(table, "goodbye");
char *val3 = kv_get(table, "fake");
printf("%s %s %s\n", val, val2, val3);
kv_delete(table, "goodbye");
val = NULL;
val = kv_get(table, "goodbye");
printf("%s %s %s\n", val, val2, val3);
kv_free(table);
table = NULL;
val = kv_get(table, "goodbye");
printf("%d\n", val);
}