commit 7edc8dbe2ea40d1a4b99e18cbb5da5fdd5d0d5b8
parent 6846c4224dd3342c4cc67e08ac4910d44802b3ad
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Tue, 1 Dec 2015 19:23:51 +0100
ed: simplify setfname
Diffstat:
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/ed.c b/ed.c
@@ -415,14 +415,10 @@ static void
setfname(char *fname)
{
char *s;
- size_t len;
if (fname == savfname)
return;
- len = strlen(fname);
- if (!(s = malloc(len + 1)))
- error("out of memory");
- memcpy(s, fname, len+1);
+ s = strdup(fname);
free(savfname);
savfname = s;
}