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

@ -808,8 +808,11 @@ int reftable_addition_add(struct reftable_addition *add,
}
tab_fd = get_tempfile_fd(tab_file);
wr = reftable_new_writer(reftable_fd_write, reftable_fd_flush, &tab_fd,
&add->stack->opts);
err = reftable_writer_new(&wr, reftable_fd_write, reftable_fd_flush,
&tab_fd, &add->stack->opts);
if (err < 0)
goto done;
err = write_table(wr, arg);
if (err < 0)
goto done;
@ -898,8 +901,11 @@ static int stack_compact_locked(struct reftable_stack *st,
goto done;
}
wr = reftable_new_writer(reftable_fd_write, reftable_fd_flush,
&tab_fd, &st->opts);
err = reftable_writer_new(&wr, reftable_fd_write, reftable_fd_flush,
&tab_fd, &st->opts);
if (err < 0)
goto done;
err = stack_write_compact(st, wr, first, last, config);
if (err < 0)
goto done;