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,28 +92,22 @@ 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)
|
||||||
{
|
{
|
||||||
buf = (float*)fftwf_malloc(size*sizeof(float));
|
if constexpr (std::is_same<T,float>::value)
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
fftwf_free(buf);
|
if constexpr (std::is_same<T, float>::value)
|
||||||
buf = nullptr;
|
fftwf_free(buf);
|
||||||
}
|
else
|
||||||
}
|
fftw_free(buf);
|
||||||
void freeimpl(double*& buf)
|
buf = nullptr;
|
||||||
{
|
|
||||||
if (buf!=nullptr)
|
|
||||||
{
|
|
||||||
fftw_free(buf);
|
|
||||||
buf = nullptr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user