Hi all, I'm looking to extract the current Celix API to the Native-OSGi project, and running into some issues related to data/memory ownership.
Celix uses APR and memory pools for memory management. In cases where the API returns some data, the user supplies a pool, and the framework allocates the needed memory on that pool. This makes the user the owner of the data. At the moment Celix doesn't solve this nicely, sometimes data is allocated on the supplied pool, sometimes a pointer is returned.. But this is another issue. Some examples of this can be found in bundle.h, eg bundle_getEntry. In the Native-OSGi specification we don't want to use APR (or impose it on others), so basically the question is, how do we want to handle functions where some data is returned? Some possible solutions: - Keep it on the call stack, so it gets out of scope. - Ignore APR, and allocate the memory, making the user responsible for freeing it. Are there any other options I am missing? And is there a common solution for problems like this? TiA! -- Met vriendelijke groet, Alexander Broekhuis
