changed: OutStreams<>::streams_map should not have null pointers to StreamType objects

git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@1018 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
Tomasz Sowa 2015-11-16 12:09:34 +00:00
parent 0dc807dbff
commit a1ea2e3ccd
3 changed files with 10 additions and 11 deletions

View File

@ -1,4 +1,4 @@
Copyright (c) 2007-2014, Tomasz Sowa
Copyright (c) 2007-2015, Tomasz Sowa
All rights reserved.
Redistribution and use in source and binary forms, with or without

View File

@ -1328,27 +1328,26 @@ void Generator<StreamType>::CopyTmpStreamToOutputStreams(Item::Function & fun, S
for(size_t s=0 ; s < fun.parameters.size() ; ++s)
{
std::wstring & name = fun.parameters[s]->name;
std::pair<typename OutStreams<StreamType>::StreamsMap::iterator, bool> iterator_inserted = output_stream_map->streams_map.insert(std::make_pair(name, (StreamType*)0));
auto imap = output_stream_map->streams_map.find(name);
StreamType * & stream = iterator_inserted.first->second;
bool inserted = iterator_inserted.second;
if( inserted )
if( imap == output_stream_map->streams_map.end() )
{
if( output_stream_map->streams_map.size() <= output_stream_map->streams_tab.size() )
if( output_stream_map->streams_map.size() < output_stream_map->streams_tab.size() )
{
/* a new stream from the pool (output_stream_tab) has been taken */
stream = output_stream_map->streams_tab[ output_stream_map->streams_map.size() - 1 ];
/* a new stream from the pool (output_stream_tab) is taken */
StreamType * stream = output_stream_map->streams_tab[ output_stream_map->streams_map.size() ];
output_stream_map->streams_map.insert(std::make_pair(name, stream));
ClearStream(*stream);
stream->write(str.c_str(), str.size());
}
else
{
CreateMsg(previous_stream, L"limit of output streams has been reached");
CreateMsg(previous_stream, L"limit of output streams in OutStreams<> has been reached");
}
}
else
{
StreamType * stream = imap->second;
stream->write(str.c_str(), str.size());
}
}

View File

@ -52,7 +52,7 @@ class OutStreams
{
public:
typedef std::map<std::wstring, StreamType*> StreamsMap; // can have null pointers
typedef std::map<std::wstring, StreamType*> StreamsMap;
typedef std::vector<StreamType*> StreamsTab;
StreamsMap streams_map;