diff options
author | William Wilgus <wilgus.william@gmail.com> | 2023-11-11 00:01:34 -0500 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2023-11-19 12:00:02 -0500 |
commit | dbe20d453d5e93bd0f1188a8851c6cf4fd230b26 (patch) | |
tree | 943a01d0aaf051bb7ad47d390bcb848058cb2404 /firmware/common/file.c | |
parent | a7d0ff200066ff4d102ffff9e24d3c2b8ef7fde5 (diff) | |
download | rockbox-dbe20d453d5e93bd0f1188a8851c6cf4fd230b26.tar.gz rockbox-dbe20d453d5e93bd0f1188a8851c6cf4fd230b26.zip |
Extend path_append_ex to truncate compname, remove some strmemdupa
remove some duplicated strings previously allocd off the stack
just removing string duplications that are easily handled with truncation
now available with path_append_ex()
this also has an advantage of less stack used in worst case scenarios
Change-Id: I3a43e33ef8a8c36599e4c6c036a0ccdd8ed0c883
Diffstat (limited to 'firmware/common/file.c')
-rw-r--r-- | firmware/common/file.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/firmware/common/file.c b/firmware/common/file.c index 202410db81..2012e2ff80 100644 --- a/firmware/common/file.c +++ b/firmware/common/file.c | |||
@@ -1056,7 +1056,7 @@ int rename(const char *old, const char *new) | |||
1056 | FILE_ERROR(EINVAL, -4); | 1056 | FILE_ERROR(EINVAL, -4); |
1057 | } | 1057 | } |
1058 | 1058 | ||
1059 | const char * const oldname = strmemdupa(oldinfo.name, oldinfo.length); | 1059 | //const char * const oldname = strmemdupa(oldinfo.name, oldinfo.length); |
1060 | const char * const newname = strmemdupa(newinfo.name, newinfo.length); | 1060 | const char * const newname = strmemdupa(newinfo.name, newinfo.length); |
1061 | bool is_overwrite = false; | 1061 | bool is_overwrite = false; |
1062 | 1062 | ||
@@ -1076,7 +1076,8 @@ int rename(const char *old, const char *new) | |||
1076 | FILE_ERROR(ERRNO, rc * 10 - 5); | 1076 | FILE_ERROR(ERRNO, rc * 10 - 5); |
1077 | } | 1077 | } |
1078 | } | 1078 | } |
1079 | else if (!strcmp(newname, oldname)) /* case-only is ok */ | 1079 | else if (!strncmp(newname, oldinfo.name, oldinfo.length) && /* case-only is ok */ |
1080 | newname[oldinfo.length] == '\0') /* make sure of actual match */ | ||
1080 | { | 1081 | { |
1081 | DEBUGF("No name change (success)\n"); | 1082 | DEBUGF("No name change (success)\n"); |
1082 | rc = 0; | 1083 | rc = 0; |