Hi Jukka, On 02/10/2015 08:42 AM, Jukka Rissanen wrote: > If user has supplied a value free function, then that will be > called for each deleted entry. > --- > ell/hashmap.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/ell/hashmap.c b/ell/hashmap.c > index f707d64..c51abfd 100644 > --- a/ell/hashmap.c > +++ b/ell/hashmap.c > @@ -349,6 +349,9 @@ LIB_EXPORT bool l_hashmap_set_value_free_function(struct l_hashmap *hashmap, > * @destroy: destroy function > * > * Free hash table and call @destory on all remaining entries. > + * If user has set the value free function by > + * l_hashmap_set_value_free_function() then the user specified free > + * function will be called in order to free the value. > **/ > LIB_EXPORT void l_hashmap_destroy(struct l_hashmap *hashmap, > l_hashmap_destroy_func_t destroy) > @@ -369,6 +372,7 @@ LIB_EXPORT void l_hashmap_destroy(struct l_hashmap *hashmap, > destroy(entry->value); > > free_key(hashmap, entry->key); > + free_value(hashmap, entry->value); So this is not the way hashmap has been designed. The destroy function (which is the last argument to this call) is being called already to cleanup memory, etc. In effect, you're now duplicating this functionality. > > next = entry->next; > > Regards, -Denis