]> Sergey Matveev's repositories - nnn.git/commitdiff
Avoid another allocation
authorsin <sin@2f30.org>
Wed, 6 Jan 2016 15:55:25 +0000 (15:55 +0000)
committersin <sin@2f30.org>
Wed, 6 Jan 2016 15:55:25 +0000 (15:55 +0000)
noice.c

diff --git a/noice.c b/noice.c
index 50674243164e52ba0e4f00246d76a8936209fdf0..d1b2c9193f4d7c41835d4bd03f9dcce98ce097c9 100644 (file)
--- a/noice.c
+++ b/noice.c
@@ -423,12 +423,12 @@ canopendir(char *path)
 void
 printent(struct entry *ent, int active)
 {
-       char *name;
+       char name[PATH_MAX];
        unsigned int maxlen = COLS - strlen(CURSR) - 1;
        char cm = 0;
 
        /* Copy name locally */
-       name = xstrdup(ent->name);
+       strlcpy(name, ent->name, sizeof(name));
 
        if (S_ISDIR(ent->mode)) {
                cm = '/';
@@ -455,8 +455,6 @@ printent(struct entry *ent, int active)
                printw("%s%s\n", active ? CURSR : EMPTY, name);
        else
                printw("%s%s%c\n", active ? CURSR : EMPTY, name, cm);
-
-       free(name);
 }
 
 int