Use constexpr if in FFTWBuffer memory helper functions
This commit is contained in:
parent
778a360cd6
commit
0eadb853f7
@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include "../JuceLibraryCode/JuceHeader.h"
|
#include "../JuceLibraryCode/JuceHeader.h"
|
||||||
#include <random>
|
#include <random>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class FFTWBuffer
|
class FFTWBuffer
|
||||||
@ -91,26 +92,20 @@ public:
|
|||||||
private:
|
private:
|
||||||
T* m_buf = nullptr;
|
T* m_buf = nullptr;
|
||||||
int m_size = 0;
|
int m_size = 0;
|
||||||
void mallocimpl(float*& buf,int size)
|
void mallocimpl(T*& buf,int size)
|
||||||
{
|
{
|
||||||
|
if constexpr (std::is_same<T,float>::value)
|
||||||
buf = (float*)fftwf_malloc(size*sizeof(float));
|
buf = (float*)fftwf_malloc(size*sizeof(float));
|
||||||
|
else
|
||||||
|
buf = (double*)fftw_malloc(size * sizeof(double));
|
||||||
}
|
}
|
||||||
void mallocimpl(double*& buf,int size)
|
void freeimpl(T*& buf)
|
||||||
{
|
|
||||||
buf = (double*)fftw_malloc(size*sizeof(double));
|
|
||||||
}
|
|
||||||
void freeimpl(float*& buf)
|
|
||||||
{
|
{
|
||||||
if (buf!=nullptr)
|
if (buf!=nullptr)
|
||||||
{
|
{
|
||||||
|
if constexpr (std::is_same<T, float>::value)
|
||||||
fftwf_free(buf);
|
fftwf_free(buf);
|
||||||
buf = nullptr;
|
else
|
||||||
}
|
|
||||||
}
|
|
||||||
void freeimpl(double*& buf)
|
|
||||||
{
|
|
||||||
if (buf!=nullptr)
|
|
||||||
{
|
|
||||||
fftw_free(buf);
|
fftw_free(buf);
|
||||||
buf = nullptr;
|
buf = nullptr;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user