summaryrefslogtreecommitdiff
path: root/src/shared/musl_missing.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/musl_missing.c')
-rw-r--r--src/shared/musl_missing.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/shared/musl_missing.c b/src/shared/musl_missing.c
index 0f8b4d1ad..a34e4eaec 100644
--- a/src/shared/musl_missing.c
+++ b/src/shared/musl_missing.c
@@ -26,17 +26,17 @@
#if HAVE_PROGRAM_INVOCATION_NAME == 0
char *program_invocation_name = NULL;
char *program_invocation_short_name = NULL;
-#endif // libc does not provide these variables
-const char *program_arg_name = NULL;
+const char *program_arg_name = NULL; /* Helper */
+#endif // libc does not provide program_invocation_[short_]name
#include "musl_missing.h"
+#if HAVE_PROGRAM_INVOCATION_NAME == 0
static void elogind_free_program_name(void) {
-
- if (program_invocation_name && (program_invocation_name != program_arg_name) && strlen(program_invocation_name))
+ if (program_invocation_name)
program_invocation_name = mfree(program_invocation_name);
- if (program_invocation_short_name && (program_invocation_short_name != program_arg_name) && strlen(program_invocation_short_name))
+ if (program_invocation_short_name)
program_invocation_short_name = mfree(program_invocation_short_name);
}
@@ -55,8 +55,11 @@ void elogind_set_program_name(const char* pcall) {
program_invocation_name = strdup(program_arg_name);
if (NULL == program_invocation_short_name)
program_invocation_short_name = strdup(basename(program_arg_name));
-#if HAVE_PROGRAM_INVOCATION_NAME == 0
atexit(elogind_free_program_name);
-#endif // libc does not provide these variables
}
+#else
+void elogind_set_program_name(const char* pcall) {
+ assert(pcall && pcall[0]);
+}
+#endif // libc does not provide program_invocation_[short_]name