clash is a generic closed hashmap that looks and behaves like a list of nullable pointers.
- C 100%
| .clang-format | ||
| clash.h | ||
| LICENSE | ||
| README.md | ||
| test.c | ||
clash
because I was bored. this time it's about ~200 LOC implementing a dynamic closed hashmap in C.
you can ignore the bottom half of the lines in clash.h, it's a SipHash implementation I copied from somewhere.
examples
// create a new map of ints
clash map = clash_new(sizeof(int));
// add a new value to the map
map = clash_set(map, "coolguy1234", &(int){4});
// doesn't actually do anything, since that key doesn't exist
clash_delete(map, "'; DROP DATABASE prod;");
// gets the previously assigned value, or NULL
int val = *(int*)clash_get(map, "coolguy1234");
// 4
printf("%d\n", val);