From 1435249cd1cac95d31403a9592018eaad9c7cb00 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sun, 24 Apr 2022 17:46:18 -0700 Subject: til_setup: add til_setup_new() helper For use when setup functions allocate their private setup to return in *res_setup. They specify the size of their private setup, and supply the free function to use. This may be libc's free() when it's a simple setup struct, or a bespoke free function when deep/complex freeing is required for cleanup. It's expected that callers will be embedding til_setup_t at the start of their private setup struct, and returning a pointer to this in *res_setup which would be the same value as a pointer to to their private setup struct. --- src/til_setup.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/til_setup.h') diff --git a/src/til_setup.h b/src/til_setup.h index 7984dd1..7f61213 100644 --- a/src/til_setup.h +++ b/src/til_setup.h @@ -7,4 +7,6 @@ struct til_setup_t { void (*free)(til_setup_t *setup); }; +void * til_setup_new(size_t size, void (*free_func)(til_setup_t *setup)); + #endif -- cgit v1.2.1