no strdup

This commit is contained in:
Connor Lane Smith
2011-05-26 06:39:12 +01:00
parent 5629972223
commit 0236550c77
2 changed files with 5 additions and 4 deletions

5
ls.c
View File

@@ -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);