Changeset 03f0da6b in OpenModelica


Ignore:
Timestamp:
2021-05-18T13:40:26+02:00 (15 months ago)
Author:
GitHub <noreply@…>
Branches:
maintenance/v1.17
Parents:
f1024952
git-author:
Andreas <38031952+AnHeuermann@…> (05/18/21 13:40:26)
git-committer:
GitHub <noreply@…> (05/18/21 13:40:26)
Message:

Fix memory leak of model info xml data (#7473)

Location:
OMCompiler/SimulationRuntime/c/simulation
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • OMCompiler/SimulationRuntime/c/simulation/simulation_info_json.c

    rad22570 r03f0da6b  
    394394  }
    395395#endif
     396  assert(xml->functionNames == NULL);
    396397  xml->functionNames = (FUNCTION_INFO*) calloc(xml->nFunctions, sizeof(FUNCTION_INFO));
     398  assert(xml->equationInfo == NULL);
    397399  xml->equationInfo = (EQUATION_INFO*) calloc(1+xml->nEquations, sizeof(EQUATION_INFO));
    398400  xml->equationInfo[0].id = 0;
     
    411413}
    412414
     415/**
     416 * @brief Deinitialize memory allocated by modelInfoInit
     417 *
     418 * @param xml   Pointer to model info xml data.
     419 */
     420void modelInfoDeinit(MODEL_DATA_XML* xml)
     421{
     422  free(xml->functionNames); xml->functionNames = NULL;
     423  free(xml->equationInfo); xml->equationInfo = NULL;
     424}
     425
    413426FUNCTION_INFO modelInfoGetFunction(MODEL_DATA_XML* xml, size_t ix)
    414427{
  • OMCompiler/SimulationRuntime/c/simulation/simulation_info_json.h

    r83be5f2b r03f0da6b  
    3838#endif
    3939
    40 extern FUNCTION_INFO modelInfoGetFunction(MODEL_DATA_XML*,size_t);
    41 extern void modelInfoInit(MODEL_DATA_XML*);
    42 extern EQUATION_INFO modelInfoGetEquation(MODEL_DATA_XML*,size_t);
    43 extern EQUATION_INFO modelInfoGetEquationIndexByProfileBlock(MODEL_DATA_XML*,size_t);
     40void modelInfoInit(MODEL_DATA_XML* xml);
     41void modelInfoDeinit(MODEL_DATA_XML* xml);
     42FUNCTION_INFO modelInfoGetFunction(MODEL_DATA_XML* xml, size_t ix);
     43EQUATION_INFO modelInfoGetEquation(MODEL_DATA_XML* xml, size_t ix);
     44EQUATION_INFO modelInfoGetEquationIndexByProfileBlock(MODEL_DATA_XML* xml, size_t ix);
    4445
    4546#ifdef __cplusplus
  • OMCompiler/SimulationRuntime/c/simulation/solver/model_help.c

    r85330b09 r03f0da6b  
    12741274  }
    12751275
     1276  /* Free model info xml data */
     1277  modelInfoDeinit(&(data->modelData->modelDataXml));
     1278
    12761279  TRACE_POP
    12771280}
Note: See TracChangeset for help on using the changeset viewer.