summaryrefslogtreecommitdiffstats
path: root/src/cgtop
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-11-15 20:07:45 +0100
committerLennart Poettering <lennart@poettering.net>2018-11-16 14:46:49 +0100
commitfdaa23af94f0e785036c52d6a603a3e2c1aff81e (patch)
tree0a1f698cbc10e359c9b05d96f7d70dcaee063875 /src/cgtop
parentsd-bus: make strict asan shut up (diff)
downloadsystemd-fdaa23af94f0e785036c52d6a603a3e2c1aff81e.tar.xz
systemd-fdaa23af94f0e785036c52d6a603a3e2c1aff81e.zip
cgtop: use automatic clean-up
Diffstat (limited to 'src/cgtop')
-rw-r--r--src/cgtop/cgtop.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c
index 69a5fde732..cf2de7eb5a 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;
}