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 );
#endif
// Find a free space chunk >= aSize
FREE_CHUNK_MAP::iterator newChunk = m_freeChunks.lower_bound( aSize );
// Is there enough space to store vertices?
if( m_freeSpace < aSize )
if( newChunk == m_freeChunks.end() )
{
bool result;
@ -294,11 +297,10 @@ bool CACHED_CONTAINER::reallocate( unsigned int aSize )
if( !result )
return false;
}
// Find a free space chunk >= aSize
FREE_CHUNK_MAP::iterator newChunk = m_freeChunks.lower_bound( aSize );
assert( newChunk != m_freeChunks.end() );
newChunk = m_freeChunks.lower_bound( aSize );
assert( newChunk != m_freeChunks.end() );
}
// Parameters of the allocated chunk
unsigned int newChunkSize = getChunkSize( *newChunk );