diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2017-12-11 15:07:18 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2017-12-11 15:07:18 +0100 |
commit | 1087a7f4ad8bb1bc9bf4472bf2734b0e4929e7d1 (patch) | |
tree | 639e403dfe0bce5c2714274d19f540223e072def /src/Resampler.cpp | |
parent | 1ed50fe16d749ac3a841650c4054d137b9cf7a10 (diff) | |
download | dabmod-1087a7f4ad8bb1bc9bf4472bf2734b0e4929e7d1.tar.gz dabmod-1087a7f4ad8bb1bc9bf4472bf2734b0e4929e7d1.tar.bz2 dabmod-1087a7f4ad8bb1bc9bf4472bf2734b0e4929e7d1.zip |
Remove references to malloc.h and use posix_memalign
Diffstat (limited to 'src/Resampler.cpp')
-rw-r--r-- | src/Resampler.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/Resampler.cpp b/src/Resampler.cpp index 8069a61..2be753e 100644 --- a/src/Resampler.cpp +++ b/src/Resampler.cpp @@ -27,7 +27,7 @@ #include "Resampler.h" #include "PcDebug.h" -#include <malloc.h> +#include <stdlib.h> #include <sys/types.h> #include <string.h> #include <stdexcept> @@ -81,7 +81,10 @@ Resampler::Resampler(size_t inputRate, size_t outputRate, size_t resolution) : myFactor = 1.0f / myFftSizeOut * outputRate / inputRate; } - myWindow = (float*)memalign(16, myFftSizeIn * sizeof(float)); + const int ret = posix_memalign((void**)(&myWindow), 16, myFftSizeIn * sizeof(float)); + if (ret != 0) { + throw std::runtime_error("memory allocation failed: " + std::to_string(ret)); + } for (size_t i = 0; i < myFftSizeIn; ++i) { myWindow[i] = (float)(0.5 * (1.0 - cos(2.0 * M_PI * i / (myFftSizeIn - 1)))); PDEBUG("Window[%zu] = %f\n", i, myWindow[i]); |