You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
keys are always copied internally (because growing the table would need to relocate them and anyway
you don't want a key do be modifiable once stored in the hashtable) ...
so you need to free you key (if alloc'd on the heap) when you don't need it anymore.
The value needs to be freed only if you are collecting it by passing a reference to the 'void **prev_data' argument (where to store the pointer to the value)
If you pass NULL the value will be freed using the callback provided at construction time.
Note that if you didn't provide any callback the value will be leaked .... you can also just pass 'free' as
callback.
In the documentation for the function (hashtable.h) I see :
@note If prev_data is not NULL, the previous data will not be released using the free_value callback
so the caller will be responsible of releasing the previous data once done with it
change the comment if you think it's not clear enough and in case I'll be happy to merge a pull request.
Do I need to free key/value after call the ht_delete function?
The text was updated successfully, but these errors were encountered: