commit d7ac85c12b58b407f6934ec99dc36405d176d1b8
parent b45d6b93453d0ff72018acf23b28e4f874713a40
Author: Matt Demanett <matt@demanett.net>
Date: Mon, 10 Mar 2025 19:36:22 -0400
Fix memory leak on deletion of any module that allocates in addChannel(). #246
Diffstat:
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/src/module.cpp b/src/module.cpp
@@ -6,6 +6,13 @@ using namespace bogaudio;
#define SKIN "skin"
+void BGModule::onRemove() {
+ while (_channels >= 1) {
+ removeChannel(_channels - 1);
+ --_channels;
+ }
+}
+
void BGModule::onReset() {
_steps = _modulationSteps;
reset();
diff --git a/src/module.hpp b/src/module.hpp
@@ -26,15 +26,10 @@ struct BGModule : Module {
std::string _skin = "default";
std::vector<SkinChangeListener*> _skinChangeListeners;
- BGModule() {
- }
- virtual ~BGModule() {
- while (_channels >= 1) {
- removeChannel(_channels - 1);
- --_channels;
- }
- }
+ BGModule() {}
+ virtual ~BGModule() {}
+ void onRemove() override;
void onReset() override;
void onSampleRateChange() override;
json_t* dataToJson() override;