summaryrefslogtreecommitdiff
path: root/firmware/common/file_internal.c
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2023-11-11 00:01:34 -0500
committerWilliam Wilgus <me.theuser@yahoo.com>2023-11-19 12:00:02 -0500
commitdbe20d453d5e93bd0f1188a8851c6cf4fd230b26 (patch)
tree943a01d0aaf051bb7ad47d390bcb848058cb2404 /firmware/common/file_internal.c
parenta7d0ff200066ff4d102ffff9e24d3c2b8ef7fde5 (diff)
downloadrockbox-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_internal.c')
-rw-r--r--firmware/common/file_internal.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/firmware/common/file_internal.c b/firmware/common/file_internal.c
index a73d9beaa2..8e0df576bf 100644
--- a/firmware/common/file_internal.c
+++ b/firmware/common/file_internal.c
@@ -433,7 +433,7 @@ static NO_INLINE int open_path_component(struct pathwalk *walkp,
433 int rc; 433 int rc;
434 434
435 /* create a null-terminated copy of the component name */ 435 /* create a null-terminated copy of the component name */
436 char *compname = strmemdupa(compp->name, compp->length); 436 //char *compname = strmemdupa(compp->name, compp->length);
437 437
438 unsigned int callflags = walkp->callflags; 438 unsigned int callflags = walkp->callflags;
439 struct pathwalk_component *parentp = compp->nextp; 439 struct pathwalk_component *parentp = compp->nextp;
@@ -455,7 +455,8 @@ static NO_INLINE int open_path_component(struct pathwalk *walkp,
455 if (rc > 1 && !(callflags & FF_NOISO)) 455 if (rc > 1 && !(callflags & FF_NOISO))
456 iso_decode_d_name(dir_fatent.name); 456 iso_decode_d_name(dir_fatent.name);
457 457
458 if (!strcasecmp(compname, dir_fatent.name)) 458 if (!strncasecmp(compp->name, dir_fatent.name, compp->length) &&
459 dir_fatent.name[compp->length] == '\0') /* make sure of actual match */
459 break; 460 break;
460 } 461 }
461 462
@@ -474,8 +475,8 @@ static NO_INLINE int open_path_component(struct pathwalk *walkp,
474 &compp->info.fatfile); 475 &compp->info.fatfile);
475 if (rc < 0) 476 if (rc < 0)
476 { 477 {
477 DEBUGF("I/O error opening file/directory %s (%d)\n", 478 DEBUGF("I/O error opening file/directory %.*s (%d)\n",
478 compname, rc); 479 compp->length, compp->name, rc);
479 return -EIO; 480 return -EIO;
480 } 481 }
481 482