mirror of
https://code.blicky.net/yorhel/ncdu.git
synced 2026-01-12 17:08:39 -09:00
dir_scan: call strlen only once
This commit is contained in:
parent
abab9d360d
commit
e1a9b30803
1 changed files with 2 additions and 2 deletions
|
|
@ -172,13 +172,13 @@ static char *dir_read(int *err) {
|
|||
}
|
||||
if(item->d_name[0] == '.' && (item->d_name[1] == 0 || (item->d_name[1] == '.' && item->d_name[2] == 0)))
|
||||
continue;
|
||||
size_t req = off+3+strlen(item->d_name);
|
||||
size_t len = strlen(item->d_name), req = off+3+len;
|
||||
if(req > buflen) {
|
||||
buflen = req < buflen*2 ? buflen*2 : req;
|
||||
buf = xrealloc(buf, buflen);
|
||||
}
|
||||
strcpy(buf+off, item->d_name);
|
||||
off += strlen(item->d_name)+1;
|
||||
off += len+1;
|
||||
}
|
||||
if(closedir(dir) < 0)
|
||||
*err = 1;
|
||||
|
|
|
|||
Loading…
Reference in a new issue