summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2021-06-18 09:25:05 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2021-06-18 09:25:05 -0400
commitb245b752bbfa02b2d3c86c8c3dca7920aaa351b1 (patch)
tree0e01a05a3724973bd2102bcf2918e899feeca71c /config.c
parent6f853c7ba14b5f4da8f1cb2da2ad63ad6753986f (diff)
Removed unnecessary `memset()` in `read_file()`, and
replaced `malloc()` with `calloc()`.
Diffstat (limited to 'config.c')
-rw-r--r--config.c5
1 files changed, 1 insertions, 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. */