]> git.ipfire.org Git - thirdparty/git.git/commit
reftable/tree: handle allocation failures
authorPatrick Steinhardt <ps@pks.im>
Wed, 2 Oct 2024 10:56:25 +0000 (12:56 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 2 Oct 2024 14:53:55 +0000 (07:53 -0700)
commit51afc709dc2f502442220954fb3e32f53eeb1e4e
tree4a91fe0c5f9ef68463ba8c3330c6068e63065498
parentd0501c8c9d0b67587e112bbe2a85746c7c11a9e8
reftable/tree: handle allocation failures

The tree interfaces of the reftable library handle both insertion and
searching of tree nodes with a single function, where the behaviour is
altered between the two via an `insert` bit. This makes it quit awkward
to handle allocation failures because on inserting we'd have to check
for `NULL` pointers and return an error, whereas on searching entries we
don't have to handle it as an allocation error.

Split up concerns of this function into two separate functions, one for
inserting entries and one for searching entries. This makes it easy for
us to check for allocation errors as `tree_insert()` should never return
a `NULL` pointer now. Adapt callers accordingly.

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