From 70f48f1f44bf419aac77de8664816a17122c8b29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Tue, 5 Jan 2021 14:47:49 +0100 Subject: Add wrapper function for free and strdup Reduces code in callers and helps avoiding memory leaks. --- linux/SystemdMeter.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'linux/SystemdMeter.c') diff --git a/linux/SystemdMeter.c b/linux/SystemdMeter.c index 61bb59b3..75c666f8 100644 --- a/linux/SystemdMeter.c +++ b/linux/SystemdMeter.c @@ -213,8 +213,7 @@ static void updateViaExec(void) { if (newline) { *newline = '\0'; } - free(systemState); - systemState = xStrdup(lineBuffer + strlen("SystemState=")); + free_and_xStrdup(&systemState, lineBuffer + strlen("SystemState=")); } else if (String_startsWith(lineBuffer, "NFailedUnits=")) { nFailedUnits = strtoul(lineBuffer + strlen("NFailedUnits="), NULL, 10); } else if (String_startsWith(lineBuffer, "NNames=")) { -- cgit v1.2.3