From: Lennart Poettering Date: Thu, 15 Nov 2018 19:07:45 +0000 (+0100) Subject: cgtop: use automatic clean-up X-Git-Tag: v240~303^2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fdaa23af94f0e785036c52d6a603a3e2c1aff81e;p=thirdparty%2Fsystemd.git cgtop: use automatic clean-up --- diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c index 69a5fde7322..cf2de7eb5a8 100644 --- a/src/cgtop/cgtop.c +++ b/src/cgtop/cgtop.c @@ -98,6 +98,8 @@ static void group_hashmap_free(Hashmap *h) { hashmap_free(h); } +DEFINE_TRIVIAL_CLEANUP_FUNC(Hashmap*, group_hashmap_free); + static const char *maybe_format_bytes(char *buf, size_t l, bool is_valid, uint64_t t) { if (!is_valid) return "-"; @@ -924,13 +926,13 @@ static const char* counting_what(void) { } int main(int argc, char *argv[]) { - int r; - Hashmap *a = NULL, *b = NULL; + _cleanup_(group_hashmap_freep) Hashmap *a = NULL, *b = NULL; unsigned iteration = 0; usec_t last_refresh = 0; bool quit = false, immediate_refresh = false; _cleanup_free_ char *root = NULL; CGroupMask mask; + int r; log_parse_environment(); log_open(); @@ -1138,8 +1140,6 @@ int main(int argc, char *argv[]) { r = 0; finish: - group_hashmap_free(a); - group_hashmap_free(b); return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; }