Use calloc() consistently - dedup - deduplicating backup program
HTML git clone git://bitreich.org/dedup/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/dedup/
DIR Log
DIR Files
DIR Refs
DIR Tags
DIR README
DIR LICENSE
---
DIR commit 022be48b38a5286cd9845f8397d8e491df80af31
DIR parent 4ae0717157fe75f8c600ff01dded24c2a723af4b
HTML Author: sin <sin@2f30.org>
Date: Tue, 26 Feb 2019 11:07:06 +0000
Use calloc() consistently
Diffstat:
M cache.c | 2 +-
M chunker.c | 10 ++++------
2 files changed, 5 insertions(+), 7 deletions(-)
---
DIR 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;
}
DIR 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;