X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fshash.c;h=da33fe8b6fab4b994ffc2c0ee3793c56f171cf7c;hb=7671589afbe5e7ff8a7f2e730ed077416e419fa8;hp=93163727655a02ba633883015d755a4780b99d1d;hpb=7efc68eb075acfe3c00fbe1a8ed2146c445f1139;p=sliver-openvswitch.git diff --git a/lib/shash.c b/lib/shash.c index 931637276..da33fe8b6 100644 --- a/lib/shash.c +++ b/lib/shash.c @@ -36,6 +36,7 @@ shash_destroy(struct shash *sh) { if (sh) { shash_clear(sh); + hmap_destroy(&sh->map); } } @@ -44,7 +45,7 @@ shash_clear(struct shash *sh) { struct shash_node *node, *next; - HMAP_FOR_EACH_SAFE (node, next, struct shash_node, node, &sh->map) { + SHASH_FOR_EACH_SAFE (node, next, sh) { hmap_remove(&sh->map, &node->node); free(node->name); free(node); @@ -57,15 +58,16 @@ shash_is_empty(const struct shash *shash) return hmap_is_empty(&shash->map); } -/* It is the caller's responsible to avoid duplicate names, if that is +/* It is the caller's responsibility to avoid duplicate names, if that is * desirable. */ -void +struct shash_node * shash_add(struct shash *sh, const char *name, void *data) { struct shash_node *node = xmalloc(sizeof *node); node->name = xstrdup(name); node->data = data; hmap_insert(&sh->map, &node->node, hash_name(name)); + return node; } void