From e3bfe36959af3029fca49ca3eeb3e05edb7420ac Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Sun, 4 Jun 2023 09:32:59 +0100 Subject: 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 --- win32/mingw.c | 9 ++------- 1 file 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) static char *getsysdir(void) { static char *buf = NULL; - char dir[PATH_MAX]; if (!buf) { buf = xzalloc(PATH_MAX); - GetSystemDirectory(dir, PATH_MAX); - realpath(dir, buf); + GetSystemDirectory(buf, PATH_MAX); } return buf; } @@ -2353,10 +2351,7 @@ void *get_proc_addr(const char *dll, const char *function, * on Windows 7. If it does, retry using LoadLibrary with an * explicit, backslash-separated path. */ if (!hnd) { - char dir[PATH_MAX], *path; - - GetSystemDirectory(dir, PATH_MAX); - path = concat_path_file(dir, dll); + char *path = concat_path_file(getsysdir(), dll); slash_to_bs(path); hnd = LoadLibrary(path); free(path); -- cgit v1.2.3-55-g6feb