noice

small file browser
git clone git://git.2f30.org/noice.git
Log | Files | Refs | README | LICENSE

commit 3459f6a5e79b1cd248185a7562565a851cea57ab
parent 7028eb1838e43ec695e9a1421c264bc5e64f2ac1
Author: lostd <lostd@2f30.org>
Date:   Wed Oct  8 17:59:35 +0300

Use asprintf(3) and avoid manual allocation

Diffstat:
noice.c | 5+----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/noice.c b/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);