mbox series

[00/10] reftable: stop using `struct strbuf`

Message ID cover.1728629612.git.ps@pks.im (mailing list archive)
Headers show
Series reftable: stop using `struct strbuf` | expand

Message

Patrick Steinhardt Oct. 11, 2024, 6:54 a.m. UTC
Hi,

this is the second patch series on my quest to make the reftable library
become a standalone library again that can be used by libgit2 without
pulling in all kinds of dependencies from the Git codebase. This part
makes us lose the dependency on `struct strbuf`, which is done due to
three reasons:

  - To make us independent of libgit.a.

  - To ensure that we use the pluggable allocators that users can set up
    via `reftable_set_alloc()`.

  - To make it possible to handle memory allocation failures.

While this leads to some duplication, we're only talking about ~70 lines
of code.

Thanks!

Patrick

Patrick Steinhardt (10):
  reftable: stop using `strbuf_addbuf()`
  reftable: stop using `strbuf_addf()`
  reftable/basics: provide new `reftable_buf` interface
  reftable: convert from `strbuf` to `reftable_buf`
  reftable/blocksource: adapt interface name
  t/unit-tests: check for `reftable_buf` allocation errors
  reftable/stack: adapt `format_name()` to handle allocation failures
  reftable/record: adapt `reftable_record_key()` to handle allocation
    failures
  reftable/stack: adapt `stack_filename()` to handle allocation failures
  reftable: handle trivial `reftable_buf` errors

 reftable/basics.c                   |  75 +++++++++-
 reftable/basics.h                   |  19 ++-
 reftable/block.c                    |  61 +++++---
 reftable/block.h                    |  14 +-
 reftable/blocksource.c              |  30 ++--
 reftable/blocksource.h              |   5 +-
 reftable/iter.c                     |   9 +-
 reftable/iter.h                     |   8 +-
 reftable/reader.c                   |  27 ++--
 reftable/record.c                   | 114 ++++++++------
 reftable/record.h                   |  21 +--
 reftable/stack.c                    | 221 ++++++++++++++++++----------
 reftable/system.h                   |   1 -
 reftable/writer.c                   | 102 ++++++++-----
 reftable/writer.h                   |   2 +-
 t/unit-tests/lib-reftable.c         |   4 +-
 t/unit-tests/lib-reftable.h         |   7 +-
 t/unit-tests/t-reftable-basics.c    |  16 +-
 t/unit-tests/t-reftable-block.c     |  53 +++----
 t/unit-tests/t-reftable-merged.c    |  32 ++--
 t/unit-tests/t-reftable-reader.c    |  12 +-
 t/unit-tests/t-reftable-readwrite.c | 134 +++++++++--------
 t/unit-tests/t-reftable-record.c    |  74 +++++-----
 t/unit-tests/t-reftable-stack.c     |  96 ++++++------
 24 files changed, 685 insertions(+), 452 deletions(-)

Comments

karthik nayak Oct. 11, 2024, 12:18 p.m. UTC | #1
Patrick Steinhardt <ps@pks.im> writes:

> Hi,
>
> this is the second patch series on my quest to make the reftable library
> become a standalone library again that can be used by libgit2 without
> pulling in all kinds of dependencies from the Git codebase. This part
> makes us lose the dependency on `struct strbuf`, which is done due to
> three reasons:
>
>   - To make us independent of libgit.a.
>
>   - To ensure that we use the pluggable allocators that users can set up
>     via `reftable_set_alloc()`.
>
>   - To make it possible to handle memory allocation failures.
>
> While this leads to some duplication, we're only talking about ~70 lines
> of code.
>

I only have a few small comments, but overall this series looks good.
Thanks

[snip]
Patrick Steinhardt Oct. 14, 2024, 1:09 p.m. UTC | #2
On Fri, Oct 11, 2024 at 05:18:26AM -0700, karthik nayak wrote:
> Patrick Steinhardt <ps@pks.im> writes:
> 
> > Hi,
> >
> > this is the second patch series on my quest to make the reftable library
> > become a standalone library again that can be used by libgit2 without
> > pulling in all kinds of dependencies from the Git codebase. This part
> > makes us lose the dependency on `struct strbuf`, which is done due to
> > three reasons:
> >
> >   - To make us independent of libgit.a.
> >
> >   - To ensure that we use the pluggable allocators that users can set up
> >     via `reftable_set_alloc()`.
> >
> >   - To make it possible to handle memory allocation failures.
> >
> > While this leads to some duplication, we're only talking about ~70 lines
> > of code.
> >
> 
> I only have a few small comments, but overall this series looks good.
> Thanks

Thanks for your review!

Patrick