Skip to content

Commit

Permalink
Fix memory leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Труфанов Александр authored and trufanov-nok committed Jan 8, 2024
1 parent 107c459 commit 9d432eb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
12 changes: 5 additions & 7 deletions ta-lib-rt/c/src/ta_func/ta_ATR.c
Original file line number Diff line number Diff line change
Expand Up @@ -581,18 +581,16 @@ double tempReal, tempATR;
/**** END GENCODE SECTION 9 - DO NOT DELETE THIS LINE ****/
{
/* insert local variable here */
if( STATE_P.optInTimePeriod <= 1 )
{
/* No smoothing needed. Just do a TRANGE. */
return FUNCTION_CALL_STATE_FREE(TRANGE)( (struct TA_TRANGE_State**) &STATE_P.StateTRANGE);
}

TA_RetCode retCode;

retCode = FUNCTION_CALL_STATE_FREE(TRANGE)( (struct TA_TRANGE_State**) &STATE_P.StateTRANGE );
if (retCode != ENUM_VALUE(RetCode,TA_SUCCESS,Success)) return retCode;
else retCode = FUNCTION_CALL_STATE_FREE(SMA)( (struct TA_SMA_State**) &STATE_P.StateSMA );
if (retCode != ENUM_VALUE(RetCode,TA_SUCCESS,Success)) return retCode;

if( STATE_P.optInTimePeriod > 1 ) {
retCode = FUNCTION_CALL_STATE_FREE(SMA)( (struct TA_SMA_State**) &STATE_P.StateSMA );
if (retCode != ENUM_VALUE(RetCode,TA_SUCCESS,Success)) return retCode;
}

/**** START GENCODE SECTION 10 - DO NOT DELETE THIS LINE ****/
/* Generated */
Expand Down
8 changes: 3 additions & 5 deletions ta-lib-rt/c/src/ta_func/ta_MA.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,12 +709,10 @@ if( STATE_P.optInTimePeriod != 1 )
default:
retValue = ENUM_VALUE(RetCode,TA_BAD_PARAM, BadParam);
}
} else {
return ENUM_VALUE(RetCode,TA_SUCCESS,Success);
}

if (retValue != ENUM_VALUE(RetCode,TA_SUCCESS,Success))
return retValue;
if (retValue != ENUM_VALUE(RetCode,TA_SUCCESS,Success))
return retValue;
}

/**** START GENCODE SECTION 10 - DO NOT DELETE THIS LINE ****/
/* Generated */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ static ErrorNumber do_test_state( const TA_History *history,
{
TA_RangeTestParam testParam;
ErrorNumber errNb;
TA_RetCode retCode;
TA_RetCode retCode = TA_SUCCESS;

(void)test;

Expand Down

0 comments on commit 9d432eb

Please sign in to comment.