diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-25 06:50:03 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-25 06:50:03 +0200 |
commit | 9434bdfaedb733e1441d87fedde8056efeda7145 (patch) | |
tree | 48b2d8c9e113170f9b64337507acd5d0981e9c87 /lib/sqfs/blk_proc/deduplicate.c | |
parent | 8f0f1f4c8047a97012c55dc057780ff76667aacc (diff) |
More refactoring of the block processor
Basically just moving functions around and renaming things.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/blk_proc/deduplicate.c')
-rw-r--r-- | lib/sqfs/blk_proc/deduplicate.c | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/lib/sqfs/blk_proc/deduplicate.c b/lib/sqfs/blk_proc/deduplicate.c deleted file mode 100644 index 08a108e..0000000 --- a/lib/sqfs/blk_proc/deduplicate.c +++ /dev/null @@ -1,49 +0,0 @@ -/* SPDX-License-Identifier: LGPL-3.0-or-later */ -/* - * deduplicate.c - * - * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at> - */ -#define SQFS_BUILDING_DLL -#include "internal.h" - -int store_block_location(sqfs_block_processor_t *proc, uint64_t offset, - uint32_t size, uint32_t chksum) -{ - size_t new_sz; - void *new; - - if (proc->num_blocks == proc->max_blocks) { - new_sz = proc->max_blocks * 2; - new = realloc(proc->blocks, sizeof(proc->blocks[0]) * new_sz); - - if (new == NULL) - return SQFS_ERROR_ALLOC; - - proc->blocks = new; - proc->max_blocks = new_sz; - } - - proc->blocks[proc->num_blocks].offset = offset; - proc->blocks[proc->num_blocks].hash = MK_BLK_HASH(chksum, size); - proc->num_blocks += 1; - return 0; -} - -size_t deduplicate_blocks(sqfs_block_processor_t *proc, size_t count) -{ - size_t i, j; - - for (i = 0; i < proc->file_start; ++i) { - for (j = 0; j < count; ++j) { - if (proc->blocks[i + j].hash != - proc->blocks[proc->file_start + j].hash) - break; - } - - if (j == count) - break; - } - - return i; -} |