More robust condition for checking sufficient space in CACHED_CONTAINER

Having enough space is not enough, we need a continuous block of memory.
This commit is contained in:
Maciej Suminski 2016-08-18 17:18:13 +02:00
parent 630d5e04fe
commit 7f5bce3772
1 changed files with 7 additions and 5 deletions

View File

@ -275,8 +275,11 @@ bool CACHED_CONTAINER::reallocate( unsigned int aSize )
wxLogDebug( wxT( "Resize %p from %d to %d" ), m_item, itemSize, aSize ); wxLogDebug( wxT( "Resize %p from %d to %d" ), m_item, itemSize, aSize );
#endif #endif
// Find a free space chunk >= aSize
FREE_CHUNK_MAP::iterator newChunk = m_freeChunks.lower_bound( aSize );
// Is there enough space to store vertices? // Is there enough space to store vertices?
if( m_freeSpace < aSize ) if( newChunk == m_freeChunks.end() )
{ {
bool result; bool result;
@ -294,11 +297,10 @@ bool CACHED_CONTAINER::reallocate( unsigned int aSize )
if( !result ) if( !result )
return false; return false;
}
// Find a free space chunk >= aSize newChunk = m_freeChunks.lower_bound( aSize );
FREE_CHUNK_MAP::iterator newChunk = m_freeChunks.lower_bound( aSize ); assert( newChunk != m_freeChunks.end() );
assert( newChunk != m_freeChunks.end() ); }
// Parameters of the allocated chunk // Parameters of the allocated chunk
unsigned int newChunkSize = getChunkSize( *newChunk ); unsigned int newChunkSize = getChunkSize( *newChunk );