[strongSwan] Remove all elements from a hashtable_t

Graham Hudspith g.w.hudspith at googlemail.com
Fri Jun 4 14:44:14 CEST 2010


Hello All,

Quick development question for you (nice on a Friday afternoon).

I've a hashtable_t containing elements and I want to delete all elements
from that hashtable_t. And use the hashtable_t again afterwards.

I can see that hashtable_t supports getting, setting and removing of
elements. These are only applicable if you know the element key before hand.

I can see that hashtable_t also supports an enumerator_t to iterate over the
elements.

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'm
worried about pulling the rug out from under the feet of the enumerator_t by
deleting items in the middle of the hashtable_t while I'm enumerating
through it.

Or, is there a better way of doing this ?

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.

Regards,

Graham.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.strongswan.org/pipermail/users/attachments/20100604/7d66cae3/attachment.html>


More information about the Users mailing list