Skip to content

Commit

Permalink
Corrected problem with array allocation.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@15264 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
smiz committed Feb 21, 2013
1 parent 09d9600 commit a7a2b72
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Compiler/Template/CodegenAdevs.tpl
Expand Up @@ -344,6 +344,7 @@ case SIMCODE(modelInfo = MODELINFO(varInfo = vi as VARINFO(__))) then
delays(NULL),
eventFuncs(NULL)
{
push_memory_states(1); // Prep the OMC C Runtime memory pool
timeValue = 0.0;
if (numRelations() > 0)
zc = new int[numRelations()];
Expand Down Expand Up @@ -388,6 +389,7 @@ case SIMCODE(modelInfo = MODELINFO(varInfo = vi as VARINFO(__))) then
if (eventFuncs[i] != NULL) delete eventFuncs[i];
delete [] eventFuncs;
}
pop_memory_states(NULL); // Delete the OMC memory pool
}

<%makeExtraResiduals(allEquations,lastIdentOfPath(modelInfo.name))%>
Expand Down Expand Up @@ -942,6 +944,9 @@ case SIMCODE(modelInfo = MODELINFO(vars = vars as SIMVARS(__))) then
<<
void <%lastIdentOfPath(modelInfo.name)%>::calc_vars(const double* q, bool doReinit)
{
// Clear the memory pool to make room for new modelica
// array allocations.
clear_current_state();
bool reInit = false;
active_model = this;
if (atEvent || doReinit) clear_event_flags();
Expand Down

0 comments on commit a7a2b72

Please sign in to comment.