mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
replace strlcpy with strmemccpy
replace applicable calls to strlcpy with calls to strmemccpy which null terminates on truncation in theory the strmemccpy calls should be slightly faster since they don't traverse the rest of the source string on truncation but I seriously doubt there is too much of that going on in the code base Change-Id: Ia0251514e36a6242bbf3f03c5e0df123aba60ed2
This commit is contained in:
parent
b25a9d8f99
commit
f6c719d7ec
43 changed files with 236 additions and 174 deletions
|
@ -853,7 +853,7 @@ static bool retrieve(struct tagcache_search *tcs, IF_DIRCACHE(int idx_id,)
|
|||
{
|
||||
struct tagfile_entry *ep =
|
||||
(struct tagfile_entry *)&tcramcache.hdr->tags[tag][seek];
|
||||
strlcpy(buf, ep->tag_data, bufsz);
|
||||
strmemccpy(buf, ep->tag_data, bufsz);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -3469,7 +3469,7 @@ static bool write_tag(int fd, const char *tagstr, const char *datastr)
|
|||
}
|
||||
|
||||
str_setlen(buf, bufsz - 1);
|
||||
strlcpy(&buf[i], "\" ", (bufsz - i - 1));
|
||||
strmemccpy(&buf[i], "\" ", (bufsz - i - 1));
|
||||
|
||||
write(fd, buf, i + 2);
|
||||
|
||||
|
@ -4737,7 +4737,7 @@ void do_tagcache_build(const char *path[])
|
|||
/* check_dir might add new roots */
|
||||
for(this = &roots_ll[0]; this; this = this->next)
|
||||
{
|
||||
strlcpy(curpath, this->path, sizeof(curpath));
|
||||
strmemccpy(curpath, this->path, sizeof(curpath));
|
||||
ret = ret && check_dir(this->path, true);
|
||||
}
|
||||
free_search_roots(&roots_ll[0]);
|
||||
|
@ -4792,7 +4792,7 @@ void tagcache_build(void)
|
|||
{
|
||||
char *vect[MAX_STATIC_ROOTS + 1]; /* +1 to ensure NULL sentinel */
|
||||
char str[sizeof(global_settings.tagcache_scan_paths)];
|
||||
strlcpy(str, global_settings.tagcache_scan_paths, sizeof(str));
|
||||
strmemccpy(str, global_settings.tagcache_scan_paths, sizeof(str));
|
||||
|
||||
int res = split_string(str, ':', vect, MAX_STATIC_ROOTS);
|
||||
vect[res] = NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue