summaryrefslogtreecommitdiff
path: root/src/til_setup.h
AgeCommit message (Collapse)Author
2022-04-24til_setup: introduce til_setup_free()Vito Caputo
simple wrapper around til_setup_t.free()
2022-04-24til_setup: add til_setup_new() helperVito Caputo
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.
2022-04-24til_setup: introduce til_setup_tVito Caputo
Preparatory commit for providing a res_setup type to replace void*. The impetus for this isn't just pursuit of less void*, but primarily implementing setup freeing by embedding this struct into the private setup types. An alternative method of adding setup freeing would have been to introduce something like til_module_t.free_setup(). But that would require having the til_module_t on hand, and the whole setup machinery is more generalized than til_module_t anyways. This way anything can simply embed the struct in their private setup instance and return the pointer to that in *res_setup. They should always be able to find their containing struct's offset from the til_setup_t* they returned. Either by using container_of(), or simply placing it at the start of the private setup struct.
© All Rights Reserved