-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
double free from Meshes in Model #299
Comments
For Context, // Load model from generated mesh
// WARNING: A shallow copy of mesh is generated, passed by value,
// as long as struct contains pointers to data and some values, we get a copy
// of mesh pointing to same data as original version... be careful!
Model LoadModelFromMesh(Mesh mesh)
{
Model model = { 0 };
model.transform = MatrixIdentity();
model.meshCount = 1;
model.meshes = (Mesh *)RL_CALLOC(model.meshCount, sizeof(Mesh));
model.meshes[0] = mesh; ///< here Seems like the |
Good catch 👍 What would be the best way around this? Something similar to the TextureUnmanaged approach we took? |
Maybe a I also had look into void SetTexture(const ::Texture& newTexture) = delete;
void SetTexture(::Texture&& newTexture) {
texture = newTexture;
newTexture = NullTexture;
} rtextures.c // Unload render texture from GPU memory (VRAM)
void UnloadRenderTexture(RenderTexture2D target)
{
if (target.id > 0)
{
if (target.texture.id > 0)
{
// Color texture attached to FBO is deleted
rlUnloadTexture(target.texture.id);
}
// NOTE: Depth texture/renderbuffer is automatically
// queried and deleted before deleting framebuffer
rlUnloadFramebuffer(target.id);
}
}
|
When loading the Models with Mesh the ownership is not clear and the mash(es)(?) got double freed.
Logs
models example
rmodel.c
The text was updated successfully, but these errors were encountered: