Re: [PATCH 02/10] reftable: stop using `strbuf_addf()`
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Oct 14, 2024, 13:09 UTC
- Message-ID
- <Zw0YFKX7p0UpdT6i@pks.im>
- In-Reply-To
- <CAOLa=ZTHuWstTD56ZVTecW7ThHhpEqmrL28Emt5DtPL6pYhcpw@mail.gmail.com>
On Fri, Oct 11, 2024 at 02:51:57AM -0700, karthik nayak wrote:
Show 21 quoted lines
> Patrick Steinhardt <ps@pks.im> writes: > > @@ -1077,8 +1078,10 @@ static void t_reftable_stack_auto_compaction_with_locked_tables(void) > > * size, we expect that auto-compaction will want to compact all of the > > * tables. Locking any of the tables will keep it from doing so. > > */ > > - strbuf_reset(&buf); > > However here it is different, since we still use the strbuf. I guess it > should be okay, since 'buf' is initialized using 'STRBUF_INIT' and that > still keeps the buf.len to 0. > > > - strbuf_addf(&buf, "%s/%s.lock", dir, st->readers[2]->name); > > + strbuf_addstr(&buf, dir); > > + strbuf_addstr(&buf, "/"); > > + strbuf_addstr(&buf, st->readers[2]->name); > > + strbuf_addstr(&buf, ".lock"); > > write_file_buf(buf.buf, "", 0); > > > > So when we do 'strbuf_addstr(&buf, ...)' it should allocate the required > memory. But the reset removal did catch my eye.
Yeah, I removed it while at it as it is completely unnecessary. I've updated the commit message to point this out.
Patrick