From 806d41273267e48611c6c1171c61afa43b88b0c0 Mon Sep 17 00:00:00 2001 From: antirez Date: Thu, 2 Jul 2020 12:50:34 +0200 Subject: Get rid of non ANSI C strdup(). --- kilo.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'kilo.c') diff --git a/kilo.c b/kilo.c index c29f626..663e69d 100644 --- a/kilo.c +++ b/kilo.c @@ -790,7 +790,9 @@ int editorOpen(char *filename) { E.dirty = 0; free(E.filename); - E.filename = strdup(filename); + size_t fnlen = strlen(filename)+1; + E.filename = malloc(fnlen); + memcpy(E.filename,filename,fnlen); fp = fopen(filename,"r"); if (!fp) { -- cgit v1.2.3