mirror of
git://git.suckless.org/sbase
synced 2024-12-23 15:34:38 +00:00
no strdup
This commit is contained in:
parent
5629972223
commit
0236550c77
4
ls.1
4
ls.1
@ -18,8 +18,8 @@ shows hidden files (those beginning with '.').
|
|||||||
lists directories themselves, not their contents.
|
lists directories themselves, not their contents.
|
||||||
.TP
|
.TP
|
||||||
.B \-l
|
.B \-l
|
||||||
lists detailed information about each file, including their permissions, links,
|
lists detailed information about each file, including their type, permissions,
|
||||||
owner, group, size, and modification time.
|
links, owner, group, size, and modification time.
|
||||||
.TP
|
.TP
|
||||||
.B \-t
|
.B \-t
|
||||||
sorts files by modification time instead of by name.
|
sorts files by modification time instead of by name.
|
||||||
|
5
ls.c
5
ls.c
@ -107,8 +107,9 @@ lsdir(const char *path)
|
|||||||
continue;
|
continue;
|
||||||
if(!(ents = realloc(ents, ++n * sizeof *ents)))
|
if(!(ents = realloc(ents, ++n * sizeof *ents)))
|
||||||
eprintf("realloc:");
|
eprintf("realloc:");
|
||||||
if(!(p = strdup(d->d_name)))
|
if(!(p = malloc(strlen(d->d_name)+1)))
|
||||||
eprintf("strdup:");
|
eprintf("malloc:");
|
||||||
|
strcpy(p, d->d_name);
|
||||||
mkent(&ents[n-1], p);
|
mkent(&ents[n-1], p);
|
||||||
}
|
}
|
||||||
closedir(dp);
|
closedir(dp);
|
||||||
|
Loading…
Reference in New Issue
Block a user