From 0734c043f9c0bcefa1a259d26304a1ff69cacbf0 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Thu, 29 Mar 2018 14:48:16 +0100 Subject: win32: save a few bytes In the recently-added code to pass applet names to child processes use local arrays to build the environment variables rather that allocating them every time. mingw_spawn can call mingw_spawn_proc instead of mingw_spawn_1. --- libbb/appletlib.c | 5 +++-- win32/process.c | 7 +++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 733d9ca12..ec6ad7ba8 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -993,9 +993,10 @@ void FAST_FUNC run_applet_no_and_exit(int applet_no, const char *name, char **ar #if ENABLE_PLATFORM_MINGW32 { - char *var = xasprintf("BB_APPLET_%d=%s", getpid(), applet_name); + char var[64]; + + sprintf(var, "BB_APPLET_%d=%s", getpid(), applet_name); putenv(var); - free(var); } #endif diff --git a/win32/process.c b/win32/process.c index 95508264b..de8f653c5 100644 --- a/win32/process.c +++ b/win32/process.c @@ -361,7 +361,7 @@ mingw_spawn(char **argv) { intptr_t ret; - ret = mingw_spawn_1(P_NOWAIT, argv[0], (char *const *)argv, environ); + ret = mingw_spawn_proc((const char **)argv); return ret == -1 ? -1 : GetProcessId((HANDLE)ret); } @@ -479,13 +479,12 @@ UNUSED_PARAM comm = applet_name; } else { - char *name, *value; + char name[32], *value; - name = xasprintf("BB_APPLET_%d", sp->pid); + sprintf(name, "BB_APPLET_%d", sp->pid); if ((value=getenv(name)) != NULL) { comm = value; } - free(name); } safe_strncpy(sp->comm, comm, COMM_LEN); return sp; -- cgit v1.2.3-55-g6feb