diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2021-06-18 09:25:05 -0400 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2021-06-18 09:25:05 -0400 |
commit | b245b752bbfa02b2d3c86c8c3dca7920aaa351b1 (patch) | |
tree | 0e01a05a3724973bd2102bcf2918e899feeca71c | |
parent | 6f853c7ba14b5f4da8f1cb2da2ad63ad6753986f (diff) |
Removed unnecessary `memset()` in `read_file()`, and
replaced `malloc()` with `calloc()`.
-rw-r--r-- | config.c | 5 |
1 files changed, 1 insertions, 4 deletions
@@ -35,7 +35,7 @@ char *read_file(const char *filename, long *size) { } /* Allocate enough space for the entire file, plus one. */ - buf = malloc(filesize+1); + buf = calloc(filesize+1, sizeof(char)); /* Return NULL, if the buffer wasn't allocated. */ if (buf == NULL) { @@ -43,9 +43,6 @@ char *read_file(const char *filename, long *size) { return NULL; } - /* Zero out the buffer. */ - memset(buf, 0, filesize+1); - /* Seek back to the start of the file. */ rewind(fp); /* Read the entire file contents into the buffer. */ |