From 74d1c18757d1a45b95e46836adf478193a34c42c Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Wed, 2 Oct 2024 12:55:48 +0200 Subject: reftable/writer: handle allocation failures in `reftable_new_writer()` Handle allocation failures in `reftable_new_writer()`. Adapt the function to return an error code to return such failures. While at it, rename it to match our code style as we have to touch up every callsite anyway. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- t/unit-tests/lib-reftable.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 't/unit-tests/lib-reftable.c') diff --git a/t/unit-tests/lib-reftable.c b/t/unit-tests/lib-reftable.c index ab1fa44a28..54c26c43e7 100644 --- a/t/unit-tests/lib-reftable.c +++ b/t/unit-tests/lib-reftable.c @@ -22,9 +22,11 @@ static int strbuf_writer_flush(void *arg UNUSED) struct reftable_writer *t_reftable_strbuf_writer(struct strbuf *buf, struct reftable_write_options *opts) { - return reftable_new_writer(&strbuf_writer_write, - &strbuf_writer_flush, - buf, opts); + struct reftable_writer *writer; + int ret = reftable_writer_new(&writer, &strbuf_writer_write, &strbuf_writer_flush, + buf, opts); + check(!ret); + return writer; } void t_reftable_write_to_buf(struct strbuf *buf, -- cgit 1.2.3-korg