file_path changes:

* improve fill_pathname_slash, no longer call strlcat
  - strlcat call would have been done in strlcat regardless
This commit is contained in:
libretroadmin 2025-07-14 17:26:15 +02:00
parent 3eb8589550
commit 2d632fed54
2 changed files with 6 additions and 4 deletions

View File

@ -372,11 +372,14 @@ size_t fill_pathname_slash(char *s, size_t len)
const char *slash = strrchr(s, '/'); const char *slash = strrchr(s, '/');
const char *backslash = strrchr(s, '\\'); const char *backslash = strrchr(s, '\\');
char *last_slash = (!slash || (backslash > slash)) ? (char*)backslash : (char*)slash; char *last_slash = (!slash || (backslash > slash)) ? (char*)backslash : (char*)slash;
len = strlen(s);
if (!last_slash) 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. */ /* 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] = last_slash[0];
s[++len] = '\0'; s[++len] = '\0';

View File

@ -628,7 +628,6 @@ void path_basedir_wrapper(char *s);
* if not already there. * if not already there.
* Hidden non-leaf function cost: * Hidden non-leaf function cost:
* - can call strlcat once if it returns false
* - calls strlen * - calls strlen
**/ **/
size_t fill_pathname_slash(char *s, size_t len); size_t fill_pathname_slash(char *s, size_t len);