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 <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2024-10-02 12:55:48 +02:00
committed by Junio C Hamano
parent b680af2dba
commit 74d1c18757
4 changed files with 38 additions and 18 deletions

View File

@ -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,