summaryrefslogtreecommitdiffstats
path: root/reftable
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-08-23 16:12:43 +0200
committerJunio C Hamano <gitster@pobox.com>2024-08-23 17:04:47 +0200
commit00e130a6bb3535de2a1a5f96640a8723fef09c87 (patch)
treecb8f40f70d07677e584ac06000bb1ce9f94f67ff /reftable
parentreftable/reader: inline `init_reader()` (diff)
downloadgit-00e130a6bb3535de2a1a5f96640a8723fef09c87.tar.xz
git-00e130a6bb3535de2a1a5f96640a8723fef09c87.zip
reftable/reader: inline `reader_close()`
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'reftable')
-rw-r--r--reftable/reader.c9
-rw-r--r--reftable/reader.h1
-rw-r--r--reftable/stack.c5
3 files changed, 3 insertions, 12 deletions
diff --git a/reftable/reader.c b/reftable/reader.c
index 9239679ad9..037417fcf6 100644
--- a/reftable/reader.c
+++ b/reftable/reader.c
@@ -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);
}
diff --git a/reftable/reader.h b/reftable/reader.h
index 762cd6de66..88b4f3b421 100644
--- a/reftable/reader.h
+++ b/reftable/reader.h
@@ -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,
diff --git a/reftable/stack.c b/reftable/stack.c
index c72435b059..0ac9cdf8de 100644
--- a/reftable/stack.c
+++ b/reftable/stack.c
@@ -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);