Open xfilesee opened 8 years ago
Hey, thanks for opening an issue :-)
If I understand you correctly, you're saying that there should be a pointer to a free
function kept in the hashtable structure that would be used to automatically free data when it's removed from the table?
If that's the case, I think it is probably a good idea to add an option for that. Although I think it might be better to do it with a callback function instead of adding another field to the structure. You might want to take a look at this related issue.
Thanks for the answer. I needed a solution immediately so I added 2 function pointers to both struct hashtable_s and hashtable_conf_s: table->key_free table->value_free By default NULL is assigned to both of these functions (to match the current configuration) and before calling I always check to make sure they are not NULL: like in hashtable_remove function: if(table->key_free != NULL) table->key_free(key);