Skip to content

How to efficiently track ressource disposal on destroy #160

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

Open
jpbruyere opened this issue Mar 23, 2025 · 0 comments
Open

How to efficiently track ressource disposal on destroy #160

jpbruyere opened this issue Mar 23, 2025 · 0 comments
Assignees

Comments

@jpbruyere
Copy link
Owner

jpbruyere commented Mar 23, 2025

When releasing any vkvg object with vkvg_*_destroy methods, there is no way to guaranty effective disposal.
If destroy succeeds, the memory allocated to the object is freed, but with the actual api, there is no way to reset the pointer to 0 or NULL. So in that state, if the pointer is used again after release, this will lead to undefined behavior.

The solution would be to return the pointer from the destroy methods (either null or valid with count > 0) or to pass a pointer of the vkvgObject to the method:

//change from:
void vkvg_destroy(VkvgContext ctx)
//to
void vkvg_destroy(VkvgContext* pCtx)
@jpbruyere jpbruyere self-assigned this Mar 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant