From: <ric...@us...> - 2010-09-08 01:03:27
|
Revision: 1071 http://loki-lib.svn.sourceforge.net/loki-lib/?rev=1071&view=rev Author: rich_sposato Date: 2010-09-08 01:03:21 +0000 (Wed, 08 Sep 2010) Log Message: ----------- Put some code within Loki::Private namespace. Modified Paths: -------------- trunk/include/loki/SmallObj.h trunk/src/SmallObj.cpp Modified: trunk/include/loki/SmallObj.h =================================================================== --- trunk/include/loki/SmallObj.h 2010-09-08 00:48:29 UTC (rev 1070) +++ trunk/include/loki/SmallObj.h 2010-09-08 01:03:21 UTC (rev 1071) @@ -75,7 +75,10 @@ } - class FixedAllocator; + namespace Private + { + class FixedAllocator; + }; // end namespace Private /** @class SmallObjAllocator @ingroup SmallObjectGroupInternal @@ -92,8 +95,8 @@ @param maxObjectSize Max # of bytes which this may allocate. @param objectAlignSize # of bytes between alignment boundaries. */ - SmallObjAllocator( std::size_t pageSize, std::size_t maxObjectSize, - std::size_t objectAlignSize ); + SmallObjAllocator( ::std::size_t pageSize, ::std::size_t maxObjectSize, + ::std::size_t objectAlignSize ); /** Destructor releases all blocks, all Chunks, and FixedAllocator's. Any outstanding blocks are unavailable, and should not be used after @@ -150,7 +153,7 @@ void Deallocate( void * p ); /// Returns max # of bytes which this can allocate. - inline std::size_t GetMaxObjectSize() const + inline ::std::size_t GetMaxObjectSize() const { return maxSmallObjectSize_; } /// Returns # of bytes between allocation boundaries. @@ -184,16 +187,15 @@ SmallObjAllocator & operator = ( const SmallObjAllocator & ); /// Pointer to array of fixed-size allocators. - Loki::FixedAllocator * pool_; + ::Loki::Private::FixedAllocator * pool_; /// Largest object size supported by allocators. - const std::size_t maxSmallObjectSize_; + const ::std::size_t maxSmallObjectSize_; /// Size of alignment boundaries. - const std::size_t objectAlignSize_; + const ::std::size_t objectAlignSize_; }; - /** @class AllocatorSingleton @ingroup SmallObjectGroupInternal This template class is derived from Modified: trunk/src/SmallObj.cpp =================================================================== --- trunk/src/SmallObj.cpp 2010-09-08 00:48:29 UTC (rev 1070) +++ trunk/src/SmallObj.cpp 2010-09-08 01:03:21 UTC (rev 1071) @@ -15,6 +15,7 @@ // $Id$ +// ---------------------------------------------------------------------------- #include <loki/SmallObj.h> @@ -32,13 +33,17 @@ #endif #if !defined( nullptr ) - #define nullptr + #define nullptr 0 #endif namespace Loki { +namespace Private +{ +// ---------------------------------------------------------------------------- + /** @struct Chunk @ingroup SmallObjectGroupInternal Contains info about each allocated Chunk - which is a collection of @@ -302,6 +307,26 @@ unsigned char FixedAllocator::MinObjectsPerChunk_ = 8; unsigned char FixedAllocator::MaxObjectsPerChunk_ = UCHAR_MAX; +/** @ingroup SmallObjectGroupInternal + Calls the default allocator when SmallObjAllocator decides not to handle a + request. SmallObjAllocator calls this if the number of bytes is bigger than + the size which can be handled by any FixedAllocator. + @param numBytes number of bytes + @param doThrow True if this function should throw an exception, or false if it + should indicate failure by returning a nullptr pointer. +*/ +void * DefaultAllocator( std::size_t numBytes, bool doThrow ); + +/** @ingroup SmallObjectGroupInternal + Calls default deallocator when SmallObjAllocator decides not to handle a + request. The default deallocator could be the global delete operator or the + free function. The free function is the preferred default deallocator since + it matches malloc which is the preferred default allocator. SmallObjAllocator + will call this if an address was not found among any of its own blocks. + */ +void DefaultDeallocator( void * p ); + + // Chunk::Init ---------------------------------------------------------------- bool Chunk::Init( std::size_t blockSize, unsigned char blocks ) @@ -1024,14 +1049,7 @@ } // DefaultAllocator ----------------------------------------------------------- -/** @ingroup SmallObjectGroupInternal - Calls the default allocator when SmallObjAllocator decides not to handle a - request. SmallObjAllocator calls this if the number of bytes is bigger than - the size which can be handled by any FixedAllocator. - @param numBytes number of bytes - @param doThrow True if this function should throw an exception, or false if it - should indicate failure by returning a nullptr pointer. -*/ + void * DefaultAllocator( std::size_t numBytes, bool doThrow ) { #ifdef USE_NEW_TO_ALLOCATE @@ -1046,13 +1064,7 @@ } // DefaultDeallocator --------------------------------------------------------- -/** @ingroup SmallObjectGroupInternal - Calls default deallocator when SmallObjAllocator decides not to handle a - request. The default deallocator could be the global delete operator or the - free function. The free function is the preferred default deallocator since - it matches malloc which is the preferred default allocator. SmallObjAllocator - will call this if an address was not found among any of its own blocks. - */ + void DefaultDeallocator( void * p ) { #ifdef USE_NEW_TO_ALLOCATE @@ -1062,6 +1074,13 @@ #endif } +// ---------------------------------------------------------------------------- + +}; // end namespace Private + +using namespace ::Loki::Private; + + // SmallObjAllocator::SmallObjAllocator --------------------------------------- SmallObjAllocator::SmallObjAllocator( std::size_t pageSize, @@ -1176,8 +1195,8 @@ { if ( nullptr == p ) return; assert( nullptr != pool_ ); - FixedAllocator * pAllocator = nullptr; - const std::size_t allocCount = GetOffset( GetMaxObjectSize(), GetAlignment() ); + ::Loki::Private::FixedAllocator * pAllocator = nullptr; + const std::size_t allocCount = ::Loki::Private::GetOffset( GetMaxObjectSize(), GetAlignment() ); Chunk * chunk = nullptr; for ( std::size_t ii = 0; ii < allocCount; ++ii ) @@ -1230,4 +1249,3 @@ } } // end namespace Loki - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |