sbase

suckless unix tools
git clone git://git.2f30.org/sbase.git
Log | Files | Refs | README | LICENSE

commit 0236550c77f528c3f05d6f0c6d721f01f6b39002
parent 56299722236031c9ba416d8129eca8726c3a79da
Author: Connor Lane Smith <cls@lubutu.com>
Date:   Thu May 26 06:39:12 +0100

no strdup
Diffstat:
ls.1 | 4++--
ls.c | 5+++--
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/ls.1 b/ls.1 @@ -18,8 +18,8 @@ shows hidden files (those beginning with '.'). lists directories themselves, not their contents. .TP .B \-l -lists detailed information about each file, including their permissions, links, -owner, group, size, and modification time. +lists detailed information about each file, including their type, permissions, +links, owner, group, size, and modification time. .TP .B \-t sorts files by modification time instead of by name. diff --git a/ls.c b/ls.c @@ -107,8 +107,9 @@ lsdir(const char *path) continue; if(!(ents = realloc(ents, ++n * sizeof *ents))) eprintf("realloc:"); - if(!(p = strdup(d->d_name))) - eprintf("strdup:"); + if(!(p = malloc(strlen(d->d_name)+1))) + eprintf("malloc:"); + strcpy(p, d->d_name); mkent(&ents[n-1], p); } closedir(dp);