]> Sergey Matveev's repositories - nnn.git/commitdiff
Use asprintf(3) and avoid manual allocation
authorlostd <lostd@2f30.org>
Wed, 8 Oct 2014 14:59:35 +0000 (17:59 +0300)
committerlostd <lostd@2f30.org>
Wed, 8 Oct 2014 14:59:35 +0000 (17:59 +0300)
noice.c

diff --git a/noice.c b/noice.c
index 08cc105e63d0613e1c6b8cd6eb229f8f58a5944e..887414859075e8000f620b92bc32962c2540c3e5 100644 (file)
--- 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);