Skip to content

Commit

Permalink
memory error fix
Browse files Browse the repository at this point in the history
  • Loading branch information
akkoyun committed Feb 1, 2024
1 parent 63cb73d commit 09f0357
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 6 deletions.
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Statistical",
"version": "2.4.1",
"version": "2.4.2",
"keywords": "Statistical, Max, Min, Average, Regression, Data, Sensor, Slope, Offset",
"description": "Function calculates statistical parameters of data stream and array",
"authors":
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Statistical
version=2.4.0
version=2.4.2
author=Gunce Akkoyun <[email protected]>
maintainer=Gunce Akkoyun <[email protected]>
sentence=Statistic, Sum, Max, Min, Sq_Sum, Arithmetic Average, Geometric Average, RMS Average, Ext RMS Average, Bubble Sort, Median, Standard Deviation, Standard Deviation Error, Coefficient Factor, Average, Stream, Regression, Slope, Data, Analyse
Expand Down
47 changes: 43 additions & 4 deletions src/Statistical.h
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,19 @@
// Control for Max Filo Size
if (_FILO_Size > 50) return(false);

// Resize Array
realloc(this->Data, _FILO_Size);
// ReSize Arrays
void* tempData = realloc(this->Data, _FILO_Size * sizeof(*this->Data));

// Control for Realloc
if (tempData == NULL) {

// End Function
return(false);

}

// Set New Array
this->Data = tempData;

// Set Array Size Variable
this->Data_Count = _FILO_Size;
Expand Down Expand Up @@ -819,8 +830,36 @@
if (_Size == 3) return(false);

// Resize Array
realloc(this->Magnitude_X, _Size);
realloc(this->Magnitude_Y, _Size);
void* _New_Magnitude_X = realloc(this->Magnitude_X, _Size);

// Control for Realloc
if (_New_Magnitude_X != NULL) {

// Set New Array
this->Magnitude_X = _New_Magnitude_X;

} else {

// End Function
return(false);

}

// Resize Array
void* _New_Magnitude_Y = realloc(this->Magnitude_Y, _Size);

// Control for Realloc
if (_New_Magnitude_Y != NULL) {

// Set New Array
this->Magnitude_Y = _New_Magnitude_Y;

} else {

// End Function
return(false);

}

// End Function
return(true);
Expand Down

0 comments on commit 09f0357

Please sign in to comment.