commit 022be48b38a5286cd9845f8397d8e491df80af31
parent 4ae0717157fe75f8c600ff01dded24c2a723af4b
Author: sin <sin@2f30.org>
Date: Tue, 26 Feb 2019 11:07:06 +0000
Use calloc() consistently
Diffstat:
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/cache.c b/cache.c
@@ -60,7 +60,7 @@ alloc_cache(void)
cache = calloc(1, sizeof(*cache));
if (cache == NULL)
- err(1, "malloc");
+ err(1, "calloc");
RB_INIT(&cache->nodes);
return cache;
}
diff --git a/chunker.c b/chunker.c
@@ -127,16 +127,14 @@ alloc_chunker(size_t cap, int fd)
{
struct chunker *chunker;
- chunker = malloc(sizeof(*chunker));
+ chunker = calloc(1, sizeof(*chunker));
if (chunker == NULL)
- err(1, "malloc");
+ err(1, "calloc");
- chunker->buf = malloc(cap);
+ chunker->buf = calloc(1, cap);
if (chunker->buf == NULL)
- err(1, "malloc");
+ err(1, "calloc");
chunker->cap = cap;
- chunker->rpos = 0;
- chunker->wpos = 0;
chunker->fd = fd;
return chunker;