fixed: in cache.cpp there was headerfile_ezc_cache macro used

(copied from cache.h)
fixed: in Generator: memory leak from block_stack
       objects pointing by block_stack_tab[].out_stream
       were not deleted
fixed: in Item: ClearCache() didn't clear all pointers
       Function::parameters table were not used




git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@979 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
Tomasz Sowa 2014-10-21 07:21:20 +00:00
parent 03fe124ad9
commit 6bd8889456
4 changed files with 28 additions and 10 deletions

View File

@ -35,10 +35,6 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef headerfile_ezc_cache
#define headerfile_ezc_cache
#include "cache.h"
#include "blocks.h"
@ -86,5 +82,3 @@ void Cache(Blocks & blocks, Item & item)
} // namespace Ezc
#endif

View File

@ -239,6 +239,8 @@ private:
void ClearFilterTab();
void ClearForStack();
void ClearBlockStack();
void ClearStream(StreamType & str);
void RemoveStackFunData(Stack & sitem);
@ -416,6 +418,7 @@ Generator<StreamType>::~Generator()
{
ClearFilterTab();
ClearForStack();
ClearBlockStack();
}
@ -564,6 +567,16 @@ void Generator<StreamType>::ClearFilterTab()
}
template<class StreamType>
void Generator<StreamType>::ClearBlockStack()
{
for(size_t i=0 ; i<block_stack_tab.size() ; ++i)
delete block_stack_tab[i].out_stream;
block_stack_tab.clear();
}
template<class StreamType>
void Generator<StreamType>::ClearForStack()
{

View File

@ -161,14 +161,20 @@ Item::~Item()
}
void Item::ClearCache(Item::Function & function)
{
function.fun_cache = 0;
function.item_block = 0;
for(size_t i=0 ; i<function.parameters.size() ; ++i)
ClearCache(*function.parameters[i]);
}
void Item::ClearCache()
{
for(size_t f = 0; f < functions.size() ; ++f)
{
functions[f].fun_cache = 0;
functions[f].item_block = 0;
}
ClearCache(functions[f]);
for(size_t i = 0; i < item_tab.size() ; ++i)
item_tab[i]->ClearCache();

View File

@ -146,6 +146,11 @@ struct Item
void Clear();
void ClearCache();
private:
void ClearCache(Item::Function & function);
};