From 8cb5b3eac1bb669b8828777489d54e9d9057fe6f Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Mon, 6 May 2019 15:04:16 +0200 Subject: Stop using variable length array in Interleaver --- src/Interleaver.cpp | 20 +++++++------------- src/Interleaver.h | 5 ++--- 2 files changed, 9 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/Interleaver.cpp b/src/Interleaver.cpp index 7d69810..cf0d235 100644 --- a/src/Interleaver.cpp +++ b/src/Interleaver.cpp @@ -28,23 +28,17 @@ #endif // _WIN32 -Interleaver::Interleaver(unsigned short I, unsigned short M, bool reverse) +Interleaver::Interleaver(unsigned short I, unsigned short M, bool reverse) : + I(I), + M(M), + N(I * M), + memSize((this->N * I) - 1) { - this->I = I; - this->M = M; - this->N = I * M; - this->memSize = (this->N * I) - 1; - this->mem = new char[memSize]; + mem.resize(memSize); setReverse(reverse); } -Interleaver::~Interleaver() -{ - delete []mem; -} - - void Interleaver::setReverse(bool state) { reverse = state; @@ -56,7 +50,7 @@ void Interleaver::reset() { j = 0; index = 0; - bzero(mem, memSize); + memset(mem.data(), 0, memSize * sizeof(mem[0])); } diff --git a/src/Interleaver.h b/src/Interleaver.h index 3afe8f0..2a32c47 100644 --- a/src/Interleaver.h +++ b/src/Interleaver.h @@ -26,13 +26,12 @@ # include "config.h" #endif +#include class Interleaver { public: Interleaver(unsigned short I, unsigned short M, bool reverse = false); - Interleaver(Interleaver& clone); - virtual ~Interleaver(); void setReverse(bool state); void encode(void* data, unsigned long size); @@ -48,7 +47,7 @@ private: unsigned long j; unsigned long index; unsigned long memSize; - char* mem; + std::vector mem; bool reverse; }; -- cgit v1.2.3