fix parameter order in calloc() calls
calloc(nmemb, bytes) allocates memory for an array of _nmemb_ elements of size _bytes_
This commit is contained in:
@@ -455,11 +455,11 @@ static bool alocateFFTBuffers(void) {
|
|||||||
|
|
||||||
if (vReal) free(vReal); // should not happen
|
if (vReal) free(vReal); // should not happen
|
||||||
if (vImag) free(vImag); // should not happen
|
if (vImag) free(vImag); // should not happen
|
||||||
if ((vReal = (float*) calloc(sizeof(float), samplesFFT)) == nullptr) return false; // calloc or die
|
if ((vReal = (float*) calloc(samplesFFT, sizeof(float))) == nullptr) return false; // calloc or die
|
||||||
if ((vImag = (float*) calloc(sizeof(float), samplesFFT)) == nullptr) return false;
|
if ((vImag = (float*) calloc(samplesFFT, sizeof(float))) == nullptr) return false;
|
||||||
#ifdef FFT_MAJORPEAK_HUMAN_EAR
|
#ifdef FFT_MAJORPEAK_HUMAN_EAR
|
||||||
if (pinkFactors) free(pinkFactors);
|
if (pinkFactors) free(pinkFactors);
|
||||||
if ((pinkFactors = (float*) calloc(sizeof(float), samplesFFT)) == nullptr) return false;
|
if ((pinkFactors = (float*) calloc(samplesFFT, sizeof(float))) == nullptr) return false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SR_DEBUG
|
#ifdef SR_DEBUG
|
||||||
@@ -510,7 +510,7 @@ void FFTcode(void * parameter)
|
|||||||
static float* oldSamples = nullptr; // previous 50% of samples
|
static float* oldSamples = nullptr; // previous 50% of samples
|
||||||
static bool haveOldSamples = false; // for sliding window FFT
|
static bool haveOldSamples = false; // for sliding window FFT
|
||||||
bool usingOldSamples = false;
|
bool usingOldSamples = false;
|
||||||
if (!oldSamples) oldSamples = (float*) calloc(sizeof(float), samplesFFT_2); // allocate on first run
|
if (!oldSamples) oldSamples = (float*) calloc(samplesFFT_2, sizeof(float)); // allocate on first run
|
||||||
if (!oldSamples) { disableSoundProcessing = true; return; } // no memory -> die
|
if (!oldSamples) { disableSoundProcessing = true; return; } // no memory -> die
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -526,7 +526,7 @@ void FFTcode(void * parameter)
|
|||||||
// recommended version optimized by @softhack007 (API version 1.9)
|
// recommended version optimized by @softhack007 (API version 1.9)
|
||||||
#if defined(WLED_ENABLE_HUB75MATRIX) && defined(CONFIG_IDF_TARGET_ESP32)
|
#if defined(WLED_ENABLE_HUB75MATRIX) && defined(CONFIG_IDF_TARGET_ESP32)
|
||||||
static float* windowWeighingFactors = nullptr;
|
static float* windowWeighingFactors = nullptr;
|
||||||
if (!windowWeighingFactors) windowWeighingFactors = (float*) calloc(sizeof(float), samplesFFT); // cache for FFT windowing factors - use heap
|
if (!windowWeighingFactors) windowWeighingFactors = (float*) calloc(samplesFFT, sizeof(float)); // cache for FFT windowing factors - use heap
|
||||||
#else
|
#else
|
||||||
static float windowWeighingFactors[samplesFFT] = {0.0f}; // cache for FFT windowing factors - use global RAM
|
static float windowWeighingFactors[samplesFFT] = {0.0f}; // cache for FFT windowing factors - use global RAM
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ void Segment::allocLeds() {
|
|||||||
portEXIT_CRITICAL(&ledsrgb_mux);
|
portEXIT_CRITICAL(&ledsrgb_mux);
|
||||||
|
|
||||||
if (oldLedsRgb) free(oldLedsRgb); // we need a bigger buffer, so free the old one first
|
if (oldLedsRgb) free(oldLedsRgb); // we need a bigger buffer, so free the old one first
|
||||||
CRGB* newLedsRgb = (CRGB*)calloc(1, size); // WLEDMM This is an OS call, so we should not wrap it in portEnterCRITICAL
|
CRGB* newLedsRgb = (CRGB*)calloc(size, 1); // WLEDMM This is an OS call, so we should not wrap it in portEnterCRITICAL
|
||||||
|
|
||||||
portENTER_CRITICAL(&ledsrgb_mux);
|
portENTER_CRITICAL(&ledsrgb_mux);
|
||||||
ledsrgb = newLedsRgb;
|
ledsrgb = newLedsRgb;
|
||||||
|
|||||||
Reference in New Issue
Block a user