From: lostd Date: Wed, 8 Oct 2014 14:59:35 +0000 (+0300) Subject: Use asprintf(3) and avoid manual allocation X-Git-Tag: v1.0~92^2~247 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=3459f6a5e79b1cd248185a7562565a851cea57ab;p=nnn.git Use asprintf(3) and avoid manual allocation --- diff --git a/noice.c b/noice.c index 08cc105e..88741485 100644 --- 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);