3 ms·
There’s another way: pass a pointer to the cleanup function as an out parameter – if it’s a struct you’re returning, just return the pointer as one of the struc
by Sharlin 4y ago
There’s another way: pass a pointer to the cleanup function as an out parameter – if it’s a struct you’re returning, just return the pointer as one of the struct fields. This is, of course, how "OO" as in methods and polymorphism is sometimes simulated in C. This way you don’t need to pollute your API with a zillion different `free_foo` functions.