From 2d632fed5425f36ea972ea789f24537cb64a7169 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Mon, 14 Jul 2025 17:26:15 +0200 Subject: [PATCH] file_path changes: * improve fill_pathname_slash, no longer call strlcat - strlcat call would have been done in strlcat regardless --- libretro-common/file/file_path.c | 9 ++++++--- libretro-common/include/file/file_path.h | 1 - 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index 9b7def5796..a60ce556f3 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -372,11 +372,14 @@ size_t fill_pathname_slash(char *s, size_t len) const char *slash = strrchr(s, '/'); const char *backslash = strrchr(s, '\\'); char *last_slash = (!slash || (backslash > slash)) ? (char*)backslash : (char*)slash; + len = strlen(s); if (!last_slash) - return strlcat(s, PATH_DEFAULT_SLASH(), len); - len = strlen(s); + { + s[ len] = PATH_DEFAULT_SLASH_C(); + s[++len] = '\0'; + } /* Try to preserve slash type. */ - if (last_slash != (s + len - 1)) + else if (last_slash != (s + len - 1)) { s[ len] = last_slash[0]; s[++len] = '\0'; diff --git a/libretro-common/include/file/file_path.h b/libretro-common/include/file/file_path.h index 708bdb5170..733e94bd93 100644 --- a/libretro-common/include/file/file_path.h +++ b/libretro-common/include/file/file_path.h @@ -628,7 +628,6 @@ void path_basedir_wrapper(char *s); * if not already there. * Hidden non-leaf function cost: - * - can call strlcat once if it returns false * - calls strlen **/ size_t fill_pathname_slash(char *s, size_t len);