52 #ifndef __PCL_StandardAllocator_h
53 #define __PCL_StandardAllocator_h
58 #include <pcl/Diagnostics.h>
98 : m_fastGrowth( fastGrowth )
99 , m_canShrink( canShrink )
143 const size_type blockHeaderSize = 4*
sizeof(
void* );
144 n += blockHeaderSize;
148 return ((n >> 3) << 3) + 8 - blockHeaderSize;
152 if ( IsFastGrowthEnabled() || n < 65536 )
157 return nn - blockHeaderSize;
162 return ((n >> 12) << 12) + 4096 - blockHeaderSize;
182 return (currentSize < newSize || m_canShrink) ? BlockSize( newSize ) : currentSize;
197 PCL_PRECONDITION( size != 0 )
198 return ::operator
new( size );
212 PCL_PRECONDITION( p !=
nullptr )
213 ::
operator delete( p );
252 m_fastGrowth = enable;
265 EnableFastGrowth( !disable );
296 m_canShrink = enable;
309 EnableShrinking( !disable );
314 bool m_fastGrowth : 1;
315 bool m_canShrink : 1;
328 PCL_PRECONDITION( p !=
nullptr )
333 #pragma warning( push )
334 #pragma warning( disable: 4100 )
338 PCL_PRECONDITION( p !=
nullptr )
341 #pragma warning( pop )
A block allocator class that uses the standard new and delete operators.
StandardAllocator(const StandardAllocator &)=default
void DisableShrinking(bool disable=true)
bool IsFastGrowthEnabled() const
void EnableShrinking(bool enable=true)
void EnableFastGrowth(bool enable=true)
bool IsShrinkingEnabled() const
void * AllocateBlock(size_type size)
size_type BlockSize(size_type n) const
void DisableFastGrowth(bool disable=true)
size_type MaxSize() const
size_type ReallocatedBlockSize(size_type currentSize, size_type newSize) const
StandardAllocator(bool fastGrowth=true, bool canShrink=true)
void DeallocateBlock(void *p)