dedup

deduplicating backup program
git clone git://git.2f30.org/dedup
Log | Files | Refs | README | LICENSE

commit f450209a3a8f19f21652cb32dd4ff1ce1efdd8fd
parent 9af5dd1c8a0f4ed051b7247ca759263f5cfee054
Author: sin <sin@2f30.org>
Date:   Thu, 21 Feb 2019 18:24:52 +0000

Don't keep all snapshots in memory during walk

Diffstat:
Mdedup.c | 11+++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/dedup.c b/dedup.c @@ -574,12 +574,14 @@ rebuild_cache(struct snapshot *snap, void *arg) void walk(int (*fn)(struct snapshot *, void *), void *arg) { - struct snapshot *snap; uint64_t i; - snap = alloc_snap(); xlseek(ifd, sizeof(snaphdr), SEEK_SET); for (i = 0; i < snaphdr.nr_snapshots; i++) { + struct snapshot *snap; + int ret; + + snap = alloc_snap(); if (xread(ifd, snap, sizeof(*snap)) == 0) errx(1, "read: unexpected EOF"); @@ -588,10 +590,11 @@ walk(int (*fn)(struct snapshot *, void *), void *arg) snap->nr_blk_descs * sizeof(snap->blk_desc[0])) == 0) errx(1, "read: unexpected EOF"); - if ((*fn)(snap, arg) == WALK_STOP) + ret = (*fn)(snap, arg); + free(snap); + if (ret == WALK_STOP) break; } - free_snap(snap); } void