Use hashmap_free_free where appropriate
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 28 Nov 2017 11:31:27 +0000 (12:31 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 28 Nov 2017 20:26:37 +0000 (21:26 +0100)
src/journal/sd-journal.c
src/test/test-mount-util.c

index 0b66987..59ddc73 100644 (file)
@@ -1978,7 +1978,6 @@ fail:
 _public_ void sd_journal_close(sd_journal *j) {
         Directory *d;
         JournalFile *f;
-        char *p;
 
         if (!j)
                 return;
@@ -2006,9 +2005,7 @@ _public_ void sd_journal_close(sd_journal *j) {
                 mmap_cache_unref(j->mmap);
         }
 
-        while ((p = hashmap_steal_first(j->errors)))
-                free(p);
-        hashmap_free(j->errors);
+        hashmap_free_free(j->errors);
 
         free(j->path);
         free(j->prefix);
index 9582d6c..2aad7f3 100644 (file)
@@ -97,10 +97,7 @@ static void test_mnt_id(void) {
                 assert_se(path_equal_ptr(hashmap_get(h, INT_TO_PTR(mnt_id2)), p));
         }
 
-        while ((p = hashmap_steal_first(h)))
-                free(p);
-
-        hashmap_free(h);
+        hashmap_free_free(h);
 }
 
 int main(int argc, char *argv[]) {