Skip to content
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

Refactor: Replace manual memory management with smart pointers #457

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ericcurtin
Copy link

Replaced all malloc/free calls with std::unique_ptr to leverage RAII for memory management. Used custom deleters where needed to handle specific free functions, such as stbi_image_free and free_sd_ctx. Simplified resource cleanup by removing explicit free calls, reducing the risk of memory leaks and improving code readability. Adjusted function calls to align with smart pointer usage, ensuring compatibility and preventing raw pointer access

Replaced all `malloc`/`free` calls with `std::unique_ptr` to leverage RAII for
memory management. Used custom deleters where needed to handle specific free
functions, such as `stbi_image_free` and `free_sd_ctx`. Simplified resource
cleanup by removing explicit `free` calls, reducing the risk of memory leaks
and improving code readability. Adjusted function calls to align with smart
pointer usage, ensuring compatibility and preventing raw pointer access

Signed-off-by: Eric Curtin <[email protected]>
@MrGeRoI
Copy link

MrGeRoI commented Nov 17, 2024

So true. I keep getting memory leaks bc it allocates memory for images but im getting crash when i trying to free them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants