From: Adrian Ratiu Date: Tue, 10 Mar 2026 14:20:52 GMT Subject: Re: [PATCH 05/10] hook: replace hook_list_clear() -> string_list_clear_func() Message-ID: <87eclrg3zv.fsf@collabora.com> In-Reply-To: On Sun, 08 Mar 2026, Eric Sunshine wrote: > 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/ Thank you for pointing this out! I will fix it in v2 together with your other suggestion.