]> git.ipfire.org Git - thirdparty/git.git/commit
reftable/writer: unify releasing memory
authorPatrick Steinhardt <ps@pks.im>
Mon, 8 Apr 2024 12:24:25 +0000 (14:24 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 9 Apr 2024 00:01:41 +0000 (17:01 -0700)
commit60dd319519b41cc5cc79bdef5ee8556297db6984
tree35117448ce7d6d36cd65d6414838bac8606fc269
parent7e892fec47645ce0b791da468fb4df6c9c6d9f37
reftable/writer: unify releasing memory

There are two code paths which release memory of the reftable writer:

  - `reftable_writer_close()` releases internal state after it has
    written data.

  - `reftable_writer_free()` releases the block that was written to and
    the writer itself.

Both code paths free different parts of the writer, and consequently the
caller must make sure to call both. And while callers mostly do this
already, this falls apart when a write failure causes the caller to skip
calling `reftable_write_close()`.

Introduce a new function `reftable_writer_release()` that releases all
internal state and call it from both paths. Like this it is fine for the
caller to not call `reftable_writer_close()`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
reftable/writer.c