chiark / gitweb /
hashmap: make hashmap_clear() work on NULL hashmaps
authorLennart Poettering <lennart@poettering.net>
Tue, 3 Jul 2012 14:15:57 +0000 (16:15 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 3 Jul 2012 14:15:57 +0000 (16:15 +0200)
src/shared/hashmap.c

index ab00957..e2395d4 100644 (file)
@@ -277,6 +277,9 @@ void hashmap_free(Hashmap*h) {
 }
 
 void hashmap_free_free(Hashmap *h) {
+        if (!h)
+                return;
+
         hashmap_clear_free(h);
         hashmap_free(h);
 }
@@ -292,7 +295,8 @@ void hashmap_clear(Hashmap *h) {
 void hashmap_clear_free(Hashmap *h) {
         void *p;
 
-        assert(h);
+        if (!h)
+                return;
 
         while ((p = hashmap_steal_first(h)))
                 free(p);