From c01ba58ec525a2458a3af6eb2fb79915eeede926 Mon Sep 17 00:00:00 2001 From: Pause for Affliction Date: Tue, 10 Nov 2020 04:40:53 -0700 Subject: [PATCH] Fix memory leak that the rpmalloc assert warns of (#5776) (Fixes #5733) Hack to take care of the assertion sent by the rpmalloc memory manager. Creates a static "free" function for NotePlayHandleManager and then shoves it right before the program ends. Co-authored-by: Pause for Affliction <47124830+Epsilon-13@users.noreply.github.com> --- include/NotePlayHandle.h | 1 + src/core/NotePlayHandle.cpp | 5 +++++ src/core/main.cpp | 3 +++ 3 files changed, 9 insertions(+) diff --git a/include/NotePlayHandle.h b/include/NotePlayHandle.h index e17a5e3a25e..71866d13b46 100644 --- a/include/NotePlayHandle.h +++ b/include/NotePlayHandle.h @@ -349,6 +349,7 @@ class NotePlayHandleManager NotePlayHandle::Origin origin = NotePlayHandle::OriginPattern ); static void release( NotePlayHandle * nph ); static void extend( int i ); + static void free(); private: static NotePlayHandle ** s_available; diff --git a/src/core/NotePlayHandle.cpp b/src/core/NotePlayHandle.cpp index c101e4edf98..d540792c048 100644 --- a/src/core/NotePlayHandle.cpp +++ b/src/core/NotePlayHandle.cpp @@ -623,3 +623,8 @@ void NotePlayHandleManager::extend( int c ) ++n; } } + +void NotePlayHandleManager::free() +{ + MM_FREE(s_available); +} diff --git a/src/core/main.cpp b/src/core/main.cpp index 29be5ff6745..36fe587574b 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -1009,5 +1009,8 @@ int main( int argc, char * * argv ) } #endif + + NotePlayHandleManager::free(); + return ret; }