I'm in the process of writing a cross-platform API in C and I need a design sanity check. I know that an API is used several different ways, even on the same project. At the start you just want to get up and running as quickly as possible, then over time you want more and more control.
So right now, at the simplest level, you just need to call Init() when you start using my API and Close() when you stop using it. But let's say you want to start handling all of the memory for Widgets yourself. Right now, you have the API doing that for you, but it allocates memory as needed and you'd rather allocate it all upfront and then used as needed. The problem is, Close will run as normal, expecting the Widget memory to be in need of freeing.
Are there any recommendations for how to best handle this? Best I can come up with are some flags that I set when managing memory through the API so that Close() knows not to touch it, but that seems rather inelegant.