From: Eric Sunshine Date: Mon, 09 Mar 2026 02:18:25 GMT Subject: Re: [PATCH 05/10] hook: replace hook_list_clear() -> string_list_clear_func() Message-ID: In-Reply-To: <20260309005416.2760030-6-adrian.ratiu@collabora.com> On Sun, Mar 8, 2026 at 8:55 PM Adrian Ratiu wrote: > Replace the custom function with string_list_clear_func() which > is a more common pattern for clearing a string_list. > > To be able to do this, rework hook_clear() into hook_free(), so > it can be passed to string_list_clear_func(). > > A slight complication is the need to keep a copy of the internal > cb data free() pointer, however I think it's worth it since the > API becomes cleaner, e.g. no more calls with NULL function args > like hook_list_clear(hooks, NULL). > > Suggested-by: Patrick Steinhardt > Signed-off-by: Adrian Ratiu > --- > diff --git a/hook.h b/hook.h > @@ -186,10 +194,10 @@ struct string_list *list_hooks(struct repository *r, const char *hookname, > /** > + * Frees a struct hook stored as the util pointer of a string_list_item. > + * Suitable for use as a string_list_clear_func_t callback. > */ > +void hook_free(void *p, const char *str UNUSED); See [*] regarding UNUSED in header file. [*]: https://lore.kernel.org/git/xmqqcy1g25fl.fsf@gitster.g/