diff options
-rw-r--r-- | src/audiocache.cc | 5 | ||||
-rw-r--r-- | src/audiocache.h | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/audiocache.cc b/src/audiocache.cc index e3be20b..2e9eaf8 100644 --- a/src/audiocache.cc +++ b/src/audiocache.cc @@ -277,7 +277,10 @@ void AudioCache::setFrameSize(std::size_t framesize) if(framesize > nodata_framesize) { - delete[] nodata; + if(nodata) + { + nodata_dirty.emplace_back(std::move(nodata)); // Store for later deletion. + } nodata = new sample_t[framesize]; nodata_framesize = framesize; diff --git a/src/audiocache.h b/src/audiocache.h index 54abcf7..9c6fa53 100644 --- a/src/audiocache.h +++ b/src/audiocache.h @@ -29,6 +29,7 @@ #include <string> #include <list> #include <vector> +#include <memory> #include "audiotypes.h" #include "audiofile.h" @@ -106,6 +107,7 @@ private: sample_t* nodata{nullptr}; std::size_t nodata_framesize{0}; std::size_t chunk_size{0}; + std::list<std::unique_ptr<sample_t[]>> nodata_dirty; AudioCacheIDManager id_manager; AudioCacheEventHandler event_handler{id_manager}; |