tUse calloc() consistently - dedup - deduplicating backup program
(HTM) git clone git://git.z3bra.org/dedup.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 022be48b38a5286cd9845f8397d8e491df80af31
(DIR) parent 4ae0717157fe75f8c600ff01dded24c2a723af4b
(HTM) 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
t@@ -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
t@@ -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;