mirror of
https://github.com/jarun/nnn.git
synced 2024-11-18 17:09:14 +00:00
Use asprintf(3) and avoid manual allocation
This commit is contained in:
parent
7028eb1838
commit
3459f6a5e7
5
noice.c
5
noice.c
|
@ -341,7 +341,6 @@ nochange:
|
|||
}
|
||||
if (ret == 3) {
|
||||
char *pathnew, *pathtmp;
|
||||
size_t pathsiz;
|
||||
char *name;
|
||||
u_int8_t type;
|
||||
char *bin;
|
||||
|
@ -355,9 +354,7 @@ nochange:
|
|||
name = dents[cur].d_name;
|
||||
type = dents[cur].d_type;
|
||||
|
||||
pathsiz = strlen(path) + 1 + strlen(name) + 1;
|
||||
pathnew = malloc(pathsiz);
|
||||
snprintf(pathnew, pathsiz, "%s/%s", path, name);
|
||||
asprintf(&pathnew, "%s/%s", path, name);
|
||||
|
||||
DPRINTF_S(name);
|
||||
DPRINTF_U(type);
|
||||
|
|
Loading…
Reference in a new issue