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 <random>
|
||||
#include <type_traits>
|
||||
|
||||
template<typename T>
|
||||
class FFTWBuffer
|
||||
@ -91,26 +92,20 @@ public:
|
||||
private:
|
||||
T* m_buf = nullptr;
|
||||
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));
|
||||
}
|
||||
void mallocimpl(double*& buf,int size)
|
||||
{
|
||||
else
|
||||
buf = (double*)fftw_malloc(size * sizeof(double));
|
||||
}
|
||||
void freeimpl(float*& buf)
|
||||
void freeimpl(T*& buf)
|
||||
{
|
||||
if (buf!=nullptr)
|
||||
{
|
||||
if constexpr (std::is_same<T, float>::value)
|
||||
fftwf_free(buf);
|
||||
buf = nullptr;
|
||||
}
|
||||
}
|
||||
void freeimpl(double*& buf)
|
||||
{
|
||||
if (buf!=nullptr)
|
||||
{
|
||||
else
|
||||
fftw_free(buf);
|
||||
buf = nullptr;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user