Skip to content

Commit

Permalink
- copy fix from r10507 to SimulationRuntime/c
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@10510 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Nov 15, 2011
1 parent cfa3f1d commit 0bda135
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions SimulationRuntime/c/util/memory_pool.c
Expand Up @@ -57,13 +57,20 @@ void* push_memory_states(int maxThreads)

void pop_memory_states(void* new_states)
{
free(current_states[0].buffer); /* TODO: Free all of them... */
free(current_states);
if (current_states)
{
free(current_states[0].buffer); /* TODO: Free all of them... */
free(current_states);
}
current_states = new_states;
}

state get_memory_state()
{
if (!current_states)
{
push_memory_states(1);
}
return current_states[0].current_state;
}

Expand All @@ -84,6 +91,10 @@ void print_state(state s)

void restore_memory_state(state restore_state)
{
if (!current_states)
{
push_memory_states(1);
}
current_states[0].current_state = restore_state;
}

Expand Down

0 comments on commit 0bda135

Please sign in to comment.