Changeset 359fa1d in OpenModelica


Ignore:
Timestamp:
2021-05-18T11:46:02+02:00 (3 years ago)
Author:
AnHeuermann <andreas.heuermann@…>
Parents:
f1024952
git-author:
Andreas <38031952+AnHeuermann@…> (05/14/21 18:47:54)
git-committer:
AnHeuermann <andreas.heuermann@…> (05/18/21 11:46:02)
Message:

Fix memory leak of model info xml data

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

Legend:

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

    rad22570 r359fa1d  
    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 r359fa1d  
    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 r359fa1d  
    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.