reftable/block: introduce block_reader_release()

Introduce a new function `block_reader_release()` that releases
resources acquired by the block reader. This function will be extended
in a subsequent commit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2024-04-08 14:16:40 +02:00
committed by Junio C Hamano
parent aac8c03cc4
commit b371221a60
3 changed files with 8 additions and 1 deletions

View File

@ -256,6 +256,11 @@ done:
return err; return err;
} }
void block_reader_release(struct block_reader *br)
{
reftable_block_done(&br->block);
}
uint8_t block_reader_type(struct block_reader *r) uint8_t block_reader_type(struct block_reader *r)
{ {
return r->block.data[r->header_off]; return r->block.data[r->header_off];

View File

@ -81,6 +81,8 @@ int block_reader_init(struct block_reader *br, struct reftable_block *bl,
uint32_t header_off, uint32_t table_block_size, uint32_t header_off, uint32_t table_block_size,
int hash_size); int hash_size);
void block_reader_release(struct block_reader *br);
/* Returns the block type (eg. 'r' for refs) */ /* Returns the block type (eg. 'r' for refs) */
uint8_t block_reader_type(struct block_reader *r); uint8_t block_reader_type(struct block_reader *r);

View File

@ -253,7 +253,7 @@ static void table_iter_block_done(struct table_iter *ti)
if (!ti->bi.br) { if (!ti->bi.br) {
return; return;
} }
reftable_block_done(&ti->bi.br->block); block_reader_release(ti->bi.br);
FREE_AND_NULL(ti->bi.br); FREE_AND_NULL(ti->bi.br);
ti->bi.last_key.len = 0; ti->bi.last_key.len = 0;