diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2021-06-11 19:48:30 -0400 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2021-06-11 19:48:30 -0400 |
commit | 1cc6f587fb5ebb807d48ce3d67783b503fdb4723 (patch) | |
tree | d8b4da0b829f73c20be2a3591b7b03cb226dc4ba | |
parent | 27b25a10265724b6ab6af297653b72c5fb8754df (diff) |
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()`.
-rw-r--r-- | config.c | 4 |
1 files changed, 1 insertions, 3 deletions
@@ -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; |