From 1cc6f587fb5ebb807d48ce3d67783b503fdb4723 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Fri, 11 Jun 2021 19:48:30 -0400 Subject: Replace call to `malloc()` with call to `calloc()` in the config parser. Because `calloc()` zeros out the allocated space, we can remove the previous call to `memset()`. --- config.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/config.c b/config.c index f14e070..0454b8b 100644 --- a/config.c +++ b/config.c @@ -130,7 +130,7 @@ config *parse_config(const char *filename) { return NULL; } - cfg = malloc(sizeof(config)); + cfg = calloc(1, sizeof(config)); /* Return NULL, if cfg wasn't allocated. */ if (cfg == NULL) { @@ -138,8 +138,6 @@ config *parse_config(const char *filename) { return NULL; } - memset(cfg, 0, sizeof(config)); - while (*tmp != '\0') { char *line = get_line(&tmp); char *value; -- cgit v1.2.3-13-gbd6f