diff options
| author | Patrick Steinhardt <ps@pks.im> | 2025-04-07 15:16:15 +0200 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-04-07 14:53:09 -0700 |
| commit | 1ac4e5e83d997887dcd051c89861292a45a3db8c (patch) | |
| tree | d843aabb8b472a1f4a523c0552f270b03f784904 /reftable/table.c | |
| parent | reftable/reader: rename data structure to "table" (diff) | |
| download | git-1ac4e5e83d997887dcd051c89861292a45a3db8c.tar.gz git-1ac4e5e83d997887dcd051c89861292a45a3db8c.zip | |
reftable/blocksource: consolidate code into a single file
The code that implements block sources is distributed across a couple of
files. Consolidate all of it into "reftable/blocksource.c" and its
accompanying header so that it is easier to locate and more self
contained.
While at it, rename some of the functions to have properly scoped names.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'reftable/table.c')
| -rw-r--r-- | reftable/table.c | 33 |
1 files changed, 5 insertions, 28 deletions
diff --git a/reftable/table.c b/reftable/table.c index 440fb559ad..d18e17b0d4 100644 --- a/reftable/table.c +++ b/reftable/table.c @@ -10,35 +10,12 @@ #include "system.h" #include "block.h" +#include "blocksource.h" #include "constants.h" #include "iter.h" #include "record.h" #include "reftable-error.h" -uint64_t block_source_size(struct reftable_block_source *source) -{ - return source->ops->size(source->arg); -} - -ssize_t block_source_read_block(struct reftable_block_source *source, - struct reftable_block *dest, uint64_t off, - uint32_t size) -{ - ssize_t result = source->ops->read_block(source->arg, dest, off, size); - dest->source = *source; - return result; -} - -void block_source_close(struct reftable_block_source *source) -{ - if (!source->ops) { - return; - } - - source->ops->close(source->arg); - source->ops = NULL; -} - static struct reftable_table_offsets * table_offsets_for(struct reftable_table *t, uint8_t typ) { @@ -249,7 +226,7 @@ int table_init_block_reader(struct reftable_table *t, struct block_reader *br, } if (block_size > guess_block_size) { - reftable_block_done(&block); + block_source_return_block(&block); err = table_get_block(t, &block, next_off, block_size); if (err < 0) { goto done; @@ -259,7 +236,7 @@ int table_init_block_reader(struct reftable_table *t, struct block_reader *br, err = block_reader_init(br, &block, header_off, t->block_size, hash_size(t->hash_id)); done: - reftable_block_done(&block); + block_source_return_block(&block); return err; } @@ -666,8 +643,8 @@ int reftable_table_new(struct reftable_table **out, *out = t; done: - reftable_block_done(&footer); - reftable_block_done(&header); + block_source_return_block(&footer); + block_source_return_block(&header); if (err) { if (t) reftable_free(t->name); |
