diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index 0b6698782da..59ddc73e88b 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -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); diff --git a/src/test/test-mount-util.c b/src/test/test-mount-util.c index 9582d6ceecf..2aad7f387c6 100644 --- a/src/test/test-mount-util.c +++ b/src/test/test-mount-util.c @@ -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[]) {