3 ms·
This is a question I've wondered myself. It's nice to see some different answers and reasoning here. The solution I came up with myself is to have a destroy()
by AndyKelley 13y ago
This is a question I've wondered myself. It's nice to see some different answers and reasoning here.
The solution I came up with myself is to have a destroy() function that is capable of cleaning up no matter what state the object is in.
Example: https://github.com/andrewrk/libgroove/blob/bc7d72589eb297342a7f8c0505e441e9b512daac/groove/playlist.c#L814 https://github.com/andrewrk/libgroove/blob/bc7d72589eb297342...
Notice all the calls to groove_playlist_destroy. And then in the destroy function it checks the conditions it has to before cleaning up.
I'm not saying it's necessarily the best answer but I think it's a pretty clean strategy.