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

bugfix: General Access Violation caused by too short lifetime of MusicDef #11

Merged
merged 1 commit into from
May 18, 2024

Conversation

piotrmacha
Copy link
Member

MusicDef is used to store music themes config, and we need it for the whole lifetime of the application. However, the object was created by CMusicSys_Bass on a stack and passed to the Engine as a reference. A moment later, the scope of CMusicSys_Bass function finished and MusicDef was deallocated despite being used by other classes.

This change moves the ownership of MusicDef to the Engine, so we can guarantee its lifetime.

As a bonus feature, I added HashString that can be used for compile-time string hashing (to uint64_t) and as an efficient key for hash maps.

@piotrmacha piotrmacha merged commit 3fdf781 into main May 18, 2024
3 checks passed
@piotrmacha piotrmacha deleted the bufix/musicdef-ownership branch May 18, 2024 23:43
This pull request was closed.
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.

1 participant