On Thu, Oct 21, 2021 at 09:54:39AM -0700, Junio C Hamano wrote: > But after reading all the users of get_midx_filename(), especially > given that it is mostly internal implementation detail inside > midx.c, I think rewriting > > f() { > char *midx = get_midx_filename(...); > > ... use midx ... > > cleanup: > free(midx); > } > > into > > f() { > struct strbuf midx; > > get_midx_filename(&midx, ...); > > ... use midx.buf ... > > cleanup: > strbuf_release(&midx); > } > > is not too bad a fix for this. I was initially worried that this was too heavy-handed an approach. But I hadn't actually tried it, and updating the half-dozen callers of get_midx_filename() took only a couple of minutes. But just because something is easy doesn't necessarily mean that it is a good idea to do ;). Luckily, this approach ended up being clean, and allows us to implement midx_bitmap_filename() without copying, open-coding, or leaking. Thanks for the nice suggestion. Taylor