From 87818659165be63891f382709073c89301c30a06 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 24 Sep 2014 08:21:15 -0600 Subject: [PATCH] dedupe: don't add extent items unless we use them Only used for collision_check and debug output, so save memory if those aren't enabled. Signed-off-by: Jens Axboe --- t/dedupe.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/t/dedupe.c b/t/dedupe.c index e51e444e..7acb090a 100644 --- a/t/dedupe.c +++ b/t/dedupe.c @@ -134,11 +134,18 @@ static int read_block(int fd, void *buf, off_t offset) static void add_item(struct chunk *c, struct item *i) { - struct extent *e; + /* + * Save some memory and don't add extent items, if we don't + * use them. + */ + if (dump_output || collision_check) { + struct extent *e; + + e = malloc(sizeof(*e)); + e->offset = i->offset; + flist_add_tail(&e->list, &c->extent_list); + } - e = malloc(sizeof(*e)); - e->offset = i->offset; - flist_add_tail(&e->list, &c->extent_list); c->count++; } -- 2.25.1