Re: [PATCH 03/10] reftable/basics: provide new `reftable_buf` interface
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Oct 14, 2024, 13:09 UTC
- Message-ID
- <Zw0YGX-o4qteQyvU@pks.im>
- In-Reply-To
- <CAOLa=ZSwHeDAFi9RTzuGAi+5ogo9L6XG2K9WHY8kmvz6v-ZAeQ@mail.gmail.com>
On Fri, Oct 11, 2024 at 05:03:39AM -0500, karthik nayak wrote:
Show 29 quoted lines
> Patrick Steinhardt <ps@pks.im> writes:
> > diff --git a/reftable/basics.h b/reftable/basics.h
> > index 4c9ef0fe6c5..4cf3f0e7593 100644
> > --- a/reftable/basics.h
> > +++ b/reftable/basics.h
> > @@ -16,6 +16,22 @@ license that can be found in the LICENSE file or at
> > #include "system.h"
> > #include "reftable-basics.h"
> >
> > +struct reftable_buf {
> > + size_t alloc;
> > + size_t len;
> > + char *buf;
> > +};
> > +#define REFTABLE_BUF_INIT { 0 }
> > +
> > +void reftable_buf_init(struct reftable_buf *buf);
> > +void reftable_buf_release(struct reftable_buf *buf);
> > +void reftable_buf_reset(struct reftable_buf *buf);
> > +int reftable_buf_setlen(struct reftable_buf *buf, size_t len);
> > +int reftable_buf_cmp(const struct reftable_buf *a, const struct reftable_buf *b);
> > +int reftable_buf_add(struct reftable_buf *buf, const void *data, size_t len);
> > +int reftable_buf_addstr(struct reftable_buf *buf, const char *s);
> > +char *reftable_buf_detach(struct reftable_buf *buf);
> > +
>
> Nit: would be nice to have some comments explaining the functions here.
> I know most of them are self-explanatory and similar to strbuf, but
> since this is supposed to be isolated, it would be nice.Fair enough. I was being lazy here because the code is internal, only. But that's not really a good excuse, I guess.
Patrick