From 2744c7bb0176dc6b86a69acd4c449ea9e269e097 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 9 Jul 2021 14:31:04 +0200 Subject: [PATCH] xdg-autostart: minor refactoring We can't say free_and_replace(exec_split[n++], quoted), because the the argument is evaluated multiple times. But I think that this form is still easier to read. --- src/xdg-autostart-generator/xdg-autostart-service.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/xdg-autostart-generator/xdg-autostart-service.c b/src/xdg-autostart-generator/xdg-autostart-service.c index d6e90302fdc..f21d3f54b13 100644 --- a/src/xdg-autostart-generator/xdg-autostart-service.c +++ b/src/xdg-autostart-generator/xdg-autostart-service.c @@ -416,8 +416,8 @@ int xdg_autostart_format_exec_start( if (!escaped) return log_oom(); - free(exec_split[n]); - exec_split[n++] = TAKE_PTR(escaped); + free_and_replace(exec_split[n], escaped); + n++; continue; } @@ -457,8 +457,8 @@ int xdg_autostart_format_exec_start( if (!quoted) return log_oom(); - free(exec_split[n]); - exec_split[n++] = TAKE_PTR(quoted); + free_and_replace(exec_split[n], quoted); + n++; } for (; exec_split[n]; n++) exec_split[n] = mfree(exec_split[n]); -- 2.47.3