Skip to content

Commit

Permalink
Explicitly clear allocated memory
Browse files Browse the repository at this point in the history
  • Loading branch information
jurihock committed Jun 11, 2024
1 parent 5b6fb5d commit b2122f2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

#include <voicesmith/Source.h>

AudioBlock::AudioBlock(const std::span<float> data_to_attach) :
data(0), view(data_to_attach) {}

AudioBlock::AudioBlock(const size_t size_to_allocate) :
data(size_to_allocate), view(data) {}

AudioBlock::AudioBlock(const std::span<float> data_to_attach) :
data(0), view(data_to_attach) {}

size_t AudioBlock::size() const {
return view.size();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class AudioBlock final {

public:

explicit AudioBlock(const std::span<float> data_to_attach);
explicit AudioBlock(const size_t size_to_allocate);
explicit AudioBlock(const std::span<float> data_to_attach);

size_t size() const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

#include <voicesmith/Source.h>

AudioBlockQueue::~AudioBlockQueue() {
blocks.clear();
memory.clear();
}

void AudioBlockQueue::resize(const size_t queuesize, const size_t blocksize) {
FIFO<AudioBlock>::clear();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ class AudioBlockQueue final : public FIFO<AudioBlock> {

public:

~AudioBlockQueue();

void resize(const size_t queuesize, const size_t blocksize);

private:

std::vector<float> memory;
std::vector<std::shared_ptr<AudioBlock>> blocks;
std::vector<float> memory;

};

0 comments on commit b2122f2

Please sign in to comment.