From b245b752bbfa02b2d3c86c8c3dca7920aaa351b1 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Fri, 18 Jun 2021 09:25:05 -0400 Subject: Removed unnecessary `memset()` in `read_file()`, and replaced `malloc()` with `calloc()`. --- config.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/config.c b/config.c index 6b1da23..d2c0ea4 100644 --- a/config.c +++ b/config.c @@ -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. */ -- cgit v1.2.3-13-gbd6f