Add sync_cache to set_state code to fix logic flaw in resetting of state and memory leak. #92

This commit is contained in:
Jason Turner
2010-03-09 02:09:05 +00:00
parent 856b682e72
commit 5c98a5d6e7
2 changed files with 92 additions and 4 deletions

View File

@@ -342,13 +342,10 @@ namespace chaiscript
void sync_cache()
{
m_stack_holder->stack->get<0>().clear();
#ifndef CHAISCRIPT_NO_THREADS
boost::shared_lock<boost::shared_mutex> l(m_mutex);
#endif
get_function_cache() = m_state.m_functions;
sync_cache_no_lock();
}
/**
@@ -670,6 +667,7 @@ namespace chaiscript
#endif
m_state = t_state;
sync_cache_no_lock();
}
@@ -688,6 +686,13 @@ namespace chaiscript
return m_stack_holder->function_cache;
}
void sync_cache_no_lock()
{
m_stack_holder->stack->get<0>().clear();
get_function_cache() = m_state.m_functions;
}
/**
* Throw a reserved_word exception if the name is not allowed