@@ -579,12 +579,6 @@ void reftable_reader_init_log_iterator(struct reftable_reader *r,
reader_init_iter(r, it, BLOCK_TYPE_LOG);
}
-void reader_close(struct reftable_reader *r)
-{
- block_source_close(&r->source);
- FREE_AND_NULL(r->name);
-}
-
int reftable_reader_new(struct reftable_reader **out,
struct reftable_block_source *source, char const *name)
{
@@ -655,7 +649,8 @@ void reftable_reader_free(struct reftable_reader *r)
{
if (!r)
return;
- reader_close(r);
+ block_source_close(&r->source);
+ FREE_AND_NULL(r->name);
reftable_free(r);
}
@@ -52,7 +52,6 @@ struct reftable_reader {
struct reftable_reader_offsets log_offsets;
};
-void reader_close(struct reftable_reader *r);
const char *reader_name(struct reftable_reader *r);
void reader_init_iter(struct reftable_reader *r,
@@ -290,7 +290,6 @@ static int reftable_stack_reload_once(struct reftable_stack *st,
const char *name = reader_name(cur[i]);
stack_filename(&table_path, st, name);
- reader_close(cur[i]);
reftable_reader_free(cur[i]);
/* On Windows, can only unlink after closing. */
@@ -299,10 +298,8 @@ static int reftable_stack_reload_once(struct reftable_stack *st,
}
done:
- for (i = 0; i < new_readers_len; i++) {
- reader_close(new_readers[i]);
+ for (i = 0; i < new_readers_len; i++)
reftable_reader_free(new_readers[i]);
- }
reftable_free(new_readers);
reftable_free(cur);
strbuf_release(&table_path);
Same as with the preceding commit, we also provide a `reader_close()` function that allows the caller to close a reader without freeing it. This is unnecessary now that all users will have an allocated version of the reader. Inline it into `reftable_reader_free()`. Signed-off-by: Patrick Steinhardt <ps@pks.im> --- reftable/reader.c | 9 ++------- reftable/reader.h | 1 - reftable/stack.c | 5 +---- 3 files changed, 3 insertions(+), 12 deletions(-)