I got a problem with expunge()
When my library gets expunge'd I want to release all the resources. I have already make the free functions but the problem is that they are in "main" interface and expunge is "manager" interface, so is there a way to call the "main" interface from the "manager" interface?
I guess this is a quiestion for the Friedens Bros. hope you can help!!
Kind regards Rene W. Olsen
Hi,
Rene W. Olsen wrote:
When my library gets expunge'd I want to release all the resources. I have already make the free functions but the problem is that they are in "main" interface and expunge is "manager" interface, so is there a way to call the "main" interface from the "manager" interface?
There are different ways to do that.
First of all, you can easily use global variables in shared libraries, although you have to make sure you arbitrate for their access when modifying them. Best only use those for global pointers that are valid throughout the lifetime of the library. I normally store IExec in a global variable.
The better approach is to store the interface pointer in the library base. When you're expunged through the manager interface, the interface still holds the pointer to the (still valid) library base, so you can still use any interface that your library offers. The interfaces themselves are deleted in DeleteLibrary.
Hope that helps...
Regards,