git/reftable
Patrick Steinhardt bcd5a4059a reftable/error: introduce out-of-memory error code
The reftable library does not use the same memory allocation functions
as the rest of the Git codebase. Instead, as the reftable library is
supposed to be usable as a standalone library without Git, it provides a
set of pluggable memory allocators.

Compared to `xmalloc()` and friends these allocators are _not_ expected
to die when an allocation fails. This design choice is concious, as a
library should leave it to its caller to handle any kind of error. While
it is very likely that the caller cannot really do much in the case of
an out-of-memory situation anyway, we are not the ones to make that
decision.

Curiously though, we never handle allocation errors even though memory
allocation functions are allowed to fail. And as we do not plug in Git's
memory allocator via `reftable_set_alloc()` either the consequence is
that we'd instead segfault as soon as we run out of memory.

While the easy fix would be to wire up `xmalloc()` and friends, it
would only fix the usage of the reftable library in Git itself. Other
users like libgit2, which is about to revive its efforts to land a
backend for reftables, wouldn't be able to benefit from this solution.

Instead, we are about to do it the hard way: adapt all allocation sites
to perform error checking. Introduce a new error code for out-of-memory
errors that we will wire up in subsequent steps.

This commit also serves as the motivator for all the remaining steps in
this series such that we do not have to repeat the same arguments in
every single subsequent commit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-10-02 07:53:50 -07:00
..
LICENSE
basics.c global: improve const correctness when assigning string constants 2024-06-07 10:30:48 -07:00
basics.h global: improve const correctness when assigning string constants 2024-06-07 10:30:48 -07:00
block.c
block.h
blocksource.c Merge branch 'ps/reftable-concurrent-compaction' 2024-09-03 09:15:03 -07:00
blocksource.h reftable/blocksource: drop malloc block source 2024-08-23 08:04:46 -07:00
constants.h
error.c reftable/error: introduce out-of-memory error code 2024-10-02 07:53:50 -07:00
iter.c Merge branch 'ps/reftable-drop-generic' 2024-08-29 11:08:16 -07:00
iter.h reftable/generic: drop interface 2024-08-22 07:59:48 -07:00
merged.c reftable/generic: drop interface 2024-08-22 07:59:48 -07:00
merged.h reftable/merged: stop using generic tables in the merged table 2024-08-22 07:59:46 -07:00
pq.c reftable: change the type of array indices to 'size_t' in reftable/pq.c 2024-08-01 09:07:28 -07:00
pq.h t-reftable-pq: make merged_iter_pqueue_check() static 2024-08-01 09:07:29 -07:00
publicbasics.c
reader.c reftable/reader: make table iterator reseekable 2024-09-16 13:57:19 -07:00
reader.h reftable/reader: introduce refcounting 2024-08-23 08:04:47 -07:00
record.c Merge branch 'ps/reftable-drop-generic' 2024-08-29 11:08:16 -07:00
record.h t/helper: inline printing of reftable records 2024-08-22 07:59:47 -07:00
reftable-blocksource.h
reftable-error.h reftable/error: introduce out-of-memory error code 2024-10-02 07:53:50 -07:00
reftable-iterator.h
reftable-malloc.h
reftable-merged.h reftable/generic: drop interface 2024-08-22 07:59:48 -07:00
reftable-reader.h reftable/reader: introduce refcounting 2024-08-23 08:04:47 -07:00
reftable-record.h t/helper: inline printing of reftable records 2024-08-22 07:59:47 -07:00
reftable-stack.h t/helper: inline `reftable_stack_print_directory()` 2024-08-22 07:59:47 -07:00
reftable-writer.h
stack.c reftable/stack: fix segfault when reload with reused readers fails 2024-08-23 08:04:48 -07:00
stack.h
system.h hash-ll: merge with "hash.h" 2024-06-14 10:26:33 -07:00
tree.c reftable: remove unnecessary curly braces in reftable/tree.c 2024-08-04 09:50:18 -07:00
tree.h
writer.c reftable: mark unused parameters in virtual functions 2024-08-17 09:46:12 -07:00
writer.h