Re: [PATCH 02/10] reftable: stop using `strbuf_addf()`
From: Patrick Steinhardt <hidden>
Date: 2024-10-14 13:09:47
On Fri, Oct 11, 2024 at 02:51:57AM -0700, karthik nayak wrote:
Patrick Steinhardt [off-list ref] writes:quoted
@@ -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.quoted
- 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