1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
William Wilgus 2023-11-11 00:01:34 -05:00 committed by William Wilgus
parent a7d0ff2000
commit dbe20d453d
6 changed files with 122 additions and 56 deletions

View file

@ -433,7 +433,7 @@ static NO_INLINE int open_path_component(struct pathwalk *walkp,
int rc;
/* create a null-terminated copy of the component name */
char *compname = strmemdupa(compp->name, compp->length);
//char *compname = strmemdupa(compp->name, compp->length);
unsigned int callflags = walkp->callflags;
struct pathwalk_component *parentp = compp->nextp;
@ -455,7 +455,8 @@ static NO_INLINE int open_path_component(struct pathwalk *walkp,
if (rc > 1 && !(callflags & FF_NOISO))
iso_decode_d_name(dir_fatent.name);
if (!strcasecmp(compname, dir_fatent.name))
if (!strncasecmp(compp->name, dir_fatent.name, compp->length) &&
dir_fatent.name[compp->length] == '\0') /* make sure of actual match */
break;
}
@ -474,8 +475,8 @@ static NO_INLINE int open_path_component(struct pathwalk *walkp,
&compp->info.fatfile);
if (rc < 0)
{
DEBUGF("I/O error opening file/directory %s (%d)\n",
compname, rc);
DEBUGF("I/O error opening file/directory %.*s (%d)\n",
compp->length, compp->name, rc);
return -EIO;
}