aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2023-06-04 09:32:59 +0100
committerRon Yorston <rmy@pobox.com>2023-06-04 09:38:51 +0100
commite3bfe36959af3029fca49ca3eeb3e05edb7420ac (patch)
tree848652adb6ed7064529495c5ec6f32cc5f17aa6e
parenta5d290b6b434c9dcc209da111b874659543cad45 (diff)
downloadbusybox-w32-e3bfe36959af3029fca49ca3eeb3e05edb7420ac.tar.gz
busybox-w32-e3bfe36959af3029fca49ca3eeb3e05edb7420ac.tar.bz2
busybox-w32-e3bfe36959af3029fca49ca3eeb3e05edb7420ac.zip
win32: code shrink
getsysdir() wasn't used in get_proc_addr() because the former called realpath() which in turn called the latter. (Commit 4c6c8d61bc) realpath() was used to adjust the case of the path name as it was visible to the user as root's home directory. (Commit b04bbc0109) Later the home directory for "root" was changed so it no longer needed getsysdir(). (Commit 385decd6bf) The remaining uses of getsysdir() don't require the path to be canonicalised, so realpath() can be removed from getsysdir() and getsysdir() can be used in get_proc_addr(). Saves 32-64 bytes
-rw-r--r--win32/mingw.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/win32/mingw.c b/win32/mingw.c
index 2cf4a45a2..86dc75861 100644
--- a/win32/mingw.c
+++ b/win32/mingw.c
@@ -1099,12 +1099,10 @@ static char *gethomedir(void)
1099static char *getsysdir(void) 1099static char *getsysdir(void)
1100{ 1100{
1101 static char *buf = NULL; 1101 static char *buf = NULL;
1102 char dir[PATH_MAX];
1103 1102
1104 if (!buf) { 1103 if (!buf) {
1105 buf = xzalloc(PATH_MAX); 1104 buf = xzalloc(PATH_MAX);
1106 GetSystemDirectory(dir, PATH_MAX); 1105 GetSystemDirectory(buf, PATH_MAX);
1107 realpath(dir, buf);
1108 } 1106 }
1109 return buf; 1107 return buf;
1110} 1108}
@@ -2353,10 +2351,7 @@ void *get_proc_addr(const char *dll, const char *function,
2353 * on Windows 7. If it does, retry using LoadLibrary with an 2351 * on Windows 7. If it does, retry using LoadLibrary with an
2354 * explicit, backslash-separated path. */ 2352 * explicit, backslash-separated path. */
2355 if (!hnd) { 2353 if (!hnd) {
2356 char dir[PATH_MAX], *path; 2354 char *path = concat_path_file(getsysdir(), dll);
2357
2358 GetSystemDirectory(dir, PATH_MAX);
2359 path = concat_path_file(dir, dll);
2360 slash_to_bs(path); 2355 slash_to_bs(path);
2361 hnd = LoadLibrary(path); 2356 hnd = LoadLibrary(path);
2362 free(path); 2357 free(path);