From 2f06ec67b746dd2266399e2f43ffe3c8e50e4eb4 Mon Sep 17 00:00:00 2001 From: gurkenhabicht Date: Thu, 14 Jun 2018 15:12:32 +0200 Subject: [PATCH] moved xError to heap.; --- src/ansi_c_implementation/NLMSvariants.c | 8 ++++---- src/cpp_implementation/NLMSvariants.cpp | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ansi_c_implementation/NLMSvariants.c b/src/ansi_c_implementation/NLMSvariants.c index 66ddce2..14a085d 100644 --- a/src/ansi_c_implementation/NLMSvariants.c +++ b/src/ansi_c_implementation/NLMSvariants.c @@ -202,7 +202,7 @@ void standardNLMS( mldata_t *mlData, point_t points[] ) { char fileName[512]; const unsigned xErrorLength = mlData->samplesCount; - double *xError = (double *) malloc ( sizeof(double) *mlData->samplesCount); + double *xError = (double *) malloc ( sizeof(double) *mlData->samplesCount + 1); unsigned i, xCount = 0; mkFileName ( fileName, sizeof(fileName), STANDARD_NLMS); @@ -280,7 +280,7 @@ void localMean ( mldata_t *mlData, point_t points[] ) { char fileName[512]; const unsigned xErrorLength = mlData->samplesCount; - double *xError = (double *) malloc ( sizeof(double) *mlData->samplesCount); + double *xError = (double *) malloc ( sizeof(double) *mlData->samplesCount + 1); unsigned i, xCount = 0; // Runtime vars @@ -363,7 +363,7 @@ void directPredecessor( mldata_t *mlData, point_t points[]) { char fileName[512]; const unsigned xErrorLength = mlData->samplesCount; - double *xError = (double *) malloc ( sizeof(double) *mlData->samplesCount); + double *xError = (double *) malloc ( sizeof(double) *mlData->samplesCount + 1); unsigned xCount = 0, i; double xActual = 0.0; @@ -443,7 +443,7 @@ void differentialPredecessor ( mldata_t *mlData, point_t points[] ) { memcpy(localWeights, mlData->weights, sizeof(double) * mlData->windowSize + 1); const unsigned xErrorLength = mlData->samplesCount; char fileName[512]; - double *xError = (double *) malloc ( sizeof(double) *mlData->samplesCount); + double *xError = (double *) malloc ( sizeof(double) *mlData->samplesCount + 1); unsigned xCount = 0, i; double xPredicted = 0.0; diff --git a/src/cpp_implementation/NLMSvariants.cpp b/src/cpp_implementation/NLMSvariants.cpp index 82a0666..9a60a08 100644 --- a/src/cpp_implementation/NLMSvariants.cpp +++ b/src/cpp_implementation/NLMSvariants.cpp @@ -270,6 +270,7 @@ void standardNLMS(mldata_t *mlData, point_t points[]) { fprintf(fp01, "\nQuadratische Varianz(x_error): %f\nMittelwert:(x_error): %f\n\n", deviation, mean); free(localWeights); + free(xError); } @@ -354,6 +355,7 @@ void localMean(mldata_t *mlData, point_t points[]) { fclose(fp4); free(localWeights); + free(xError); } /* @@ -435,6 +437,7 @@ void directPredecessor(mldata_t *mlData, point_t points[]) { fclose(fp3); free(localWeights); + free(xError); } /* @@ -522,6 +525,7 @@ void differentialPredecessor(mldata_t *mlData, point_t points[]) { fclose(fp6); free(localWeights); + free(xError); } /*