[strongSwan] Remove all elements from a hashtable_t

Martin Willi martin at strongswan.org
Sat Jun 5 09:12:29 CEST 2010

Hi Graham,

> It seems to me that the only way to delete all elements in the
> hashtable_t is to create an enumerator, enumerate over the elements
> and call remove for each element found.


> Does the hashtable_t+enumerator_t support this mode of operation ?

I think so. The hashtable is based on many linked_lists, and the remove
function from list can handle this.

@Tobias: Please correct me if I'm wrong.

> Or, is there a better way of doing this ?

Our list has handy destroy_offset/destroy_function helpers for cleanup
purposes, but the hashtable is currently missing these functions. So:

> If all else fails, it may be better to free all the memory that the
> elements point to and to then destroy the hashtable_t and create a new
> one.

Might be a little more efficient for large tables (?), but shouldn't
really matter.


More information about the Users mailing list