skifli
Backend Developer
Hiya everyone,
It's been a while since I've posted here, but I was looking for some feedback on a Hashmap I had recently implemented for my programming language in C. I haven't programmed in C for a few months (had and have a lot of school-related work), so I was mainly wondering if I there were any bugs lurking in the code, mainly to do with the resizing logic (in the
exeme-lang/src/utils/hashmap.c at main · exeme-project/exeme-lang (I think a link is better so there is more context? If not I can specifically post the code here.)
The usage is like so:
It's been a while since I've posted here, but I was looking for some feedback on a Hashmap I had recently implemented for my programming language in C. I haven't programmed in C for a few months (had and have a lot of school-related work), so I was mainly wondering if I there were any bugs lurking in the code, mainly to do with the resizing logic (in the
hashmap___resize
function). I've tested the code myself, and it seems to have worked... but it was the first try, and I don't recall the last time my code worked on the first try in any language, let alone C. The link to the code is at the bottom, and just so you know, the panic
function is just a custom little helper function I made myself that prints the string passed to it and then exits. If you have any more questions relating to the code feel free to ask me 🙂.exeme-lang/src/utils/hashmap.c at main · exeme-project/exeme-lang (I think a link is better so there is more context? If not I can specifically post the code here.)
The usage is like so:
C:
#include "./utils/hashmap.c"
int main(int argc, char **argv) {
struct Hashmap *map = hashmap_new(hashmap___hashDJB2, DEFAULT_INITIAL_TABLE_COUNT, DEFAULT_LOAD_FACTOR);
hashmap_set(map, "key", "value");
hashmap_set(map, "key", "value2");
printf("%s\n", hashmap_get(map, "key")); // "value2"
hashmap_free(&map);
}