diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-11-28 12:35:49 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-11-28 21:30:30 +0100 |
commit | 224b0e7ad0116579f830b7dd387b97c3facb65d9 (patch) | |
tree | d769049843011ec955d86af31e2f0d62c4521f38 /src/sysusers | |
parent | Use hashmap_free_free where appropriate (diff) | |
download | systemd-224b0e7ad0116579f830b7dd387b97c3facb65d9.tar.xz systemd-224b0e7ad0116579f830b7dd387b97c3facb65d9.zip |
Add set/hashmap helpers for non-trivial freeing and use where straighforward
A macro is needed because otherwise we couldn't ensure type safety.
Some simple tests are included.
No functional change intended.
Diffstat (limited to 'src/sysusers')
-rw-r--r-- | src/sysusers/sysusers.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c index 909a4ca542..d8009458ee 100644 --- a/src/sysusers/sysusers.c +++ b/src/sysusers/sysusers.c @@ -1864,20 +1864,15 @@ int main(int argc, char *argv[]) { log_error_errno(r, "Failed to write files: %m"); finish: - while ((i = hashmap_steal_first(groups))) - item_free(i); - - while ((i = hashmap_steal_first(users))) - item_free(i); + hashmap_free_with_destructor(groups, item_free); + hashmap_free_with_destructor(users, item_free); while ((n = hashmap_first_key(members))) { strv_free(hashmap_steal_first(members)); free(n); } - - hashmap_free(groups); - hashmap_free(users); hashmap_free(members); + hashmap_free(todo_uids); hashmap_free(todo_gids); |