Skip to content

Commit

Permalink
Get rid of non ANSI C strdup().
Browse files Browse the repository at this point in the history
  • Loading branch information
antirez committed Jul 2, 2020
1 parent e10bc60 commit 806d412
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion kilo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 806d412

Please sign in to comment.