hashset.c
hashset.c copied to clipboard
strings don't really work
I found this out much too late...
int main(int argc, char* argv[])
{
char *foo = "foo";
char *missing = "missing";
hashset_t set = hashset_create();
if (set == NULL) {
fprintf(stderr, "failed to create hashset instance\n");
abort();
}
hashset_add(set, foo);
printf("%d\n", hashset_is_member(set, foo));
printf("%d\n", hashset_is_member(set, _strdup(foo));
}
This will print 1 0
The red flag here should have been that you weren't asked to provide your own hash function. That means it can only possibly be hashing the pointer.