Subject: Re: [PATCH v2 1/8] hook: add internal state alloc/free callbacks

From: Adrian Ratiu <[email-masked]>
Date: Fri, 20 Feb 2026 14:42:29 +0200

On Thu, 19 Feb 2026, Junio C Hamano <[email-masked]> wrote:
> Adrian Ratiu <[email-masked]> writes:
<snip>
>> -
>> -	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.