Re: [PATCH v2 1/8] hook: add internal state alloc/free callbacks
- From
Adrian Ratiu <adrian.ratiu@collabora.com>
- Date
- Feb 20, 2026, 12:42 UTC
- Message-ID
- <87ikbry4ay.fsf@collabora.com>
- In-Reply-To
- <xmqq4inc2yom.fsf@gitster.g>
On Thu, 19 Feb 2026, Junio C Hamano <gitster@pobox.com> wrote:
> Adrian Ratiu <adrian.ratiu@collabora.com> writes:
<snip>
Show 17 quoted lines
>> - >> - strbuf_init(&feed_ctx.buf, 0); >> + opt.feed_pipe_cb_data_alloc = transaction_feed_cb_data_alloc; >> + opt.feed_pipe_cb_data_free = transaction_feed_cb_data_free; >> >> ret = run_hooks_opt(transaction->ref_store->repo, "reference-transaction", &opt); >> >> - strbuf_release(&feed_ctx.buf); > > As the run_hooks_opt() machinery internally manages the > feed_pipe_cb_data, starting from the call to the custom alloc > function and concliding with the call to the custom free function, > this function no longer need to manage resources. Instead, the > custom alloc/free functions take care of all the associated > resources, like the feed_ctx.buf strbuf, as we have seen earlier. > > Nice.
Exactly, yes.
This reminds me: I need to verify the header files and the APIs to remove/update any comments about callers having to manage the these resources.
Will do in v3.