Hope someone can help me deal with this situation. Here is the problem. I have a shared library (.so, .dll, .dynlib). Inside this library there is some kind of factory class that creates objects. For example, my method looked like this:
class RenderSystem {
public:
int createTexture(Texture** texture, ...);
....
}
The method createTexturein the class is RenderSystemas follows:
int createTexture(Texture** texture, ...) {
....
*texture = new ...
return someErrorCode;
}
He created an instance Textureand passed a pointer to a parameter Texture. We know that instances created in a shared library must be destroyed the same way. Therefore, I had methods that removed / destroyed these textures.
shared_ptr , . a std::shared_ptr<Texture> . std::shared_ptr<Texture> std::shared_ptr<Texutre>? :
int createTexture(std::shared_ptr<Texture>& texture, ...) {
....
texture = std::shared_ptr<....>(...) or std::make_shared<...>(..);
return someErrorCode;
}
, .