From: Zbigniew Jędrzejewski-Szmek Date: Fri, 9 Jul 2021 12:31:04 +0000 (+0200) Subject: xdg-autostart: minor refactoring X-Git-Tag: v250-rc1~966^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2744c7bb0176dc6b86a69acd4c449ea9e269e097;p=thirdparty%2Fsystemd.git 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. --- 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]);