2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 14:25:26 +00:00

shash: New functions shash_destroy_free_data() and shash_clear_free_data().

This commit is contained in:
Ben Pfaff
2010-06-07 16:58:57 -07:00
parent e3648418c4
commit a90b56b770
2 changed files with 26 additions and 0 deletions

View File

@@ -40,6 +40,16 @@ shash_destroy(struct shash *sh)
}
}
/* Like shash_destroy(), but also free() each node's 'data'. */
void
shash_destroy_free_data(struct shash *sh)
{
if (sh) {
shash_clear_free_data(sh);
hmap_destroy(&sh->map);
}
}
void
shash_swap(struct shash *a, struct shash *b)
{
@@ -64,6 +74,20 @@ shash_clear(struct shash *sh)
}
}
/* Like shash_clear(), but also free() each node's 'data'. */
void
shash_clear_free_data(struct shash *sh)
{
struct shash_node *node, *next;
SHASH_FOR_EACH_SAFE (node, next, sh) {
hmap_remove(&sh->map, &node->node);
free(node->data);
free(node->name);
free(node);
}
}
bool
shash_is_empty(const struct shash *shash)
{