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>
This commit is contained in:

committed by
Junio C Hamano

parent
9391b88dab
commit
66c0dabab5
@ -421,7 +421,7 @@ int block_reader_seek(struct block_reader *br, struct block_iter *it,
|
||||
done:
|
||||
strbuf_release(&key);
|
||||
strbuf_release(&next.last_key);
|
||||
reftable_record_destroy(&rec);
|
||||
reftable_record_release(&rec);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
Reference in New Issue
Block a user