summaryrefslogtreecommitdiff
path: root/src/libudev/hashmap.c
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2013-06-04 13:17:54 -0400
committerAnthony G. Basile <blueness@gentoo.org>2013-06-04 13:17:54 -0400
commit730b8403f9dc3e106379595e5667373f2eedb82e (patch)
treebba2a2d1246c5ecd00ba3a7e81c1f62b7498ee63 /src/libudev/hashmap.c
parentf7ba1295c3f1ee5ee26cd8a389fd6cd0983105c8 (diff)
src/libudev/hashmap.{c,h}: bring in line with upstream
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/libudev/hashmap.c')
-rw-r--r--src/libudev/hashmap.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/libudev/hashmap.c b/src/libudev/hashmap.c
index dcfbb67228..9f7db34397 100644
--- a/src/libudev/hashmap.c
+++ b/src/libudev/hashmap.c
@@ -103,7 +103,7 @@ static void deallocate_tile(void **first_tile, void *p) {
*first_tile = p;
}
-#ifndef __OPTIMIZE__
+#ifdef VALGRIND
static void drop_pool(struct pool *p) {
while (p) {
@@ -309,6 +309,17 @@ void hashmap_free_free(Hashmap *h) {
hashmap_free(h);
}
+void hashmap_free_free_free(Hashmap *h) {
+
+ /* Free the hashmap and all data and key objects in it */
+
+ if (!h)
+ return;
+
+ hashmap_clear_free_free(h);
+ hashmap_free(h);
+}
+
void hashmap_clear(Hashmap *h) {
if (!h)
return;
@@ -327,6 +338,22 @@ void hashmap_clear_free(Hashmap *h) {
free(p);
}
+void hashmap_clear_free_free(Hashmap *h) {
+ if (!h)
+ return;
+
+ while (h->iterate_list_head) {
+ void *a, *b;
+
+ a = h->iterate_list_head->value;
+ b = (void*) h->iterate_list_head->key;
+ remove_entry(h, h->iterate_list_head);
+ free(a);
+ free(b);
+ }
+}
+
+
static struct hashmap_entry *hash_scan(Hashmap *h, unsigned hash, const void *key) {
struct hashmap_entry *e;
assert(h);