projects
/
openvswitch
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e364841
)
shash: New functions shash_destroy_free_data() and shash_clear_free_data().
author
Ben Pfaff
<blp@nicira.com>
Mon, 7 Jun 2010 23:58:57 +0000
(16:58 -0700)
committer
Ben Pfaff
<blp@nicira.com>
Thu, 17 Jun 2010 17:30:19 +0000
(10:30 -0700)
lib/shash.c
patch
|
blob
|
history
lib/shash.h
patch
|
blob
|
history
diff --git
a/lib/shash.c
b/lib/shash.c
index 1a85b7924455b4fa1f5bca77872662bae27b9236..c4d3ccb8daa524b586dc4471d1365e40e401c65d 100644
(file)
--- a/
lib/shash.c
+++ b/
lib/shash.c
@@
-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)
{
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)
{
bool
shash_is_empty(const struct shash *shash)
{
diff --git
a/lib/shash.h
b/lib/shash.h
index de8504527f77b2ea85dabf4d9290d5e3f3ff768b..f97e6616d09c70087122841e775c4f742a108024 100644
(file)
--- a/
lib/shash.h
+++ b/
lib/shash.h
@@
-44,9
+44,11
@@
struct shash {
void shash_init(struct shash *);
void shash_destroy(struct shash *);
void shash_init(struct shash *);
void shash_destroy(struct shash *);
+void shash_destroy_free_data(struct shash *);
void shash_swap(struct shash *, struct shash *);
void shash_moved(struct shash *);
void shash_clear(struct shash *);
void shash_swap(struct shash *, struct shash *);
void shash_moved(struct shash *);
void shash_clear(struct shash *);
+void shash_clear_free_data(struct shash *);
bool shash_is_empty(const struct shash *);
size_t shash_count(const struct shash *);
struct shash_node *shash_add(struct shash *, const char *, const void *);
bool shash_is_empty(const struct shash *);
size_t shash_count(const struct shash *);
struct shash_node *shash_add(struct shash *, const char *, const void *);