]> git.ipfire.org Git - thirdparty/git.git/commit
reftable: make reftable_record a tagged union
authorHan-Wen Nienhuys <hanwen@google.com>
Thu, 20 Jan 2022 15:12:13 +0000 (15:12 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 20 Jan 2022 19:31:53 +0000 (11:31 -0800)
commit66c0dabab5e15f78d0505be36cac4a383e14cf88
treedb6fd2622162b3d16eceb899975472e16d14e2c3
parent9391b88dab5145f01c9b8c3d79dba567058086e1
reftable: make reftable_record a tagged union

This reduces the amount of glue code, because we don't need a void
pointer or vtable within the structure.

The only snag is that reftable_index_record contain a strbuf, so it
cannot be zero-initialized. To address this, use reftable_new_record()
to return fresh instance, given a record type. Since
reftable_new_record() doesn't cause heap allocation anymore, it should
be balanced with reftable_record_release() rather than
reftable_record_destroy().

Thanks to Peff for the suggestion.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 files changed:
reftable/block.c
reftable/block_test.c
reftable/generic.c
reftable/iter.c
reftable/merged.c
reftable/pq.c
reftable/pq_test.c
reftable/reader.c
reftable/record.c
reftable/record.h
reftable/record_test.c
reftable/writer.c