You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by db...@apache.org on 2004/08/07 21:58:31 UTC

cvs commit: xml-xalan/c/src/xalanc/PlatformSupport ReusableArenaBlock.hpp

dbertoni    2004/08/07 12:58:31

  Modified:    c/src/xalanc/PlatformSupport ReusableArenaBlock.hpp
  Log:
  Changes for gcc 2.95.3 and some general cleanup.
  
  Revision  Changes    Path
  1.8       +22 -27    xml-xalan/c/src/xalanc/PlatformSupport/ReusableArenaBlock.hpp
  
  Index: ReusableArenaBlock.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/PlatformSupport/ReusableArenaBlock.hpp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ReusableArenaBlock.hpp	21 Jul 2004 18:01:12 -0000	1.7
  +++ ReusableArenaBlock.hpp	7 Aug 2004 19:58:31 -0000	1.8
  @@ -27,8 +27,7 @@
   
   template<> struct CompileTimeError<true>{};
   
  -#define STATIC_CHECK(expr) \
  -	CompileTimeError<(expr) != 0 >()
  +#define XALAN_STATIC_CHECK(expr) CompileTimeError<bool(expr)>()
   
   
   template <class ObjectType,
  @@ -41,16 +40,16 @@
   class ReusableArenaBlock : public ArenaBlockBase<ObjectType, size_Type>
   {
   
  -#define VALID_OBJECT_STAMP 0xffddffdd
  -
   public:
   
  -	typedef ArenaBlockBase<ObjectType, size_Type>				BaseClassType;
  +	typedef ArenaBlockBase<ObjectType, size_Type>	BaseClassType;
   
   	typedef typename BaseClassType::size_type		size_type;
   
   	struct NextBlock
   	{
  +        enum { VALID_OBJECT_STAMP = 0xffddffdd };
  +
   		size_type		next;
   		const int		verificationStamp;
   		
  @@ -63,7 +62,7 @@
   		bool
   		isValidFor( size_type  rightBorder ) const
   		{
  -			return ( ( verificationStamp == (int)VALID_OBJECT_STAMP ) &&
  +			return ( ( verificationStamp == VALID_OBJECT_STAMP ) &&
   				( next <= rightBorder ) ) ? true : false ;
   		}
   	};
  @@ -82,10 +81,9 @@
   		m_nextFreeBlock(0)
   
   	{
  -		STATIC_CHECK(sizeof(ObjectType) >= sizeof(NextBlock));
  +		XALAN_STATIC_CHECK(sizeof(ObjectType) >= sizeof(NextBlock));
   		
  -		for( size_type i = 0; i < this->
  -		m_blockSize ; ++i )
  +		for( size_type i = 0; i < this->m_blockSize; ++i )
   		{
   			new ( reinterpret_cast<NextBlock*>(&(this->m_objectBlock[i])) ) NextBlock( (size_type)(i + 1) );
   		}
  @@ -120,7 +118,6 @@
   	ObjectType*
   	allocateBlock()
   	{
  -		
   		if ( this->m_objectCount == this->m_blockSize )
   		{
   			assert ( this->m_firstFreeBlock == (this->m_blockSize + 1) );
  @@ -157,9 +154,7 @@
   			}
   
   			return theResult;
  -
   		}
  -		
   	}
   
   	/*
  @@ -189,9 +184,9 @@
   		if ( this->m_firstFreeBlock != this->m_nextFreeBlock )
   		{
   			// return it to pull of the free blocks
  -			NextBlock* p = reinterpret_cast<NextBlock*>( this->m_objectBlock + this->m_firstFreeBlock );
  +			void* const     p = this->m_objectBlock + this->m_firstFreeBlock;
   
  -			p = new (p) NextBlock(this->m_nextFreeBlock);
  +			new (p) NextBlock(this->m_nextFreeBlock);
   
   			this->m_nextFreeBlock = this->m_firstFreeBlock;
   		}
  @@ -201,16 +196,13 @@
   
   		theObject->~ObjectType();
   
  -		NextBlock* newFreeBlock = reinterpret_cast<NextBlock*>(theObject);
  -
  -		newFreeBlock = new (newFreeBlock) NextBlock(this->m_firstFreeBlock);
  +		new (theObject) NextBlock(this->m_firstFreeBlock);
   
   		m_firstFreeBlock = this->m_nextFreeBlock = size_type(theObject - this->m_objectBlock);
   
   		assert (this->m_firstFreeBlock <= this->m_blockSize);
   
   		--this->m_objectCount;
  -
   	}
   
   	/*
  @@ -245,16 +237,18 @@
   	shouldDestroyBlock(const ObjectType*	theObject) const
   	{
   		assert( size_type(theObject - this->m_objectBlock) < this->m_blockSize);
  -		return !isOnFreeList(theObject);
  +
  +        return !isOnFreeList(theObject);
   	}
   
   	bool
  -	isOccupiedBlock(const NextBlock* block)const
  +	isOccupiedBlock(const NextBlock*    block)const
   	{
   		assert( block !=0 );
   
   		return !( ownsBlock(reinterpret_cast<const ObjectType*>(block)) && block->isValidFor(this->m_blockSize) );
   	}
  +
   private:
   
   	// Not implemented...
  @@ -284,9 +278,9 @@
   		}
   		else
   		{
  -			ObjectType* pRunPtr = this->m_objectBlock + this->m_firstFreeBlock;
  +			ObjectType*     pRunPtr = this->m_objectBlock + this->m_firstFreeBlock;
   
  -			for ( int i = 0; i < (this->m_blockSize - this->m_objectCount); i++)
  +			for ( size_type i = 0; i < (this->m_blockSize - this->m_objectCount); ++i)
   			{
   				assert ( ownsBlock( pRunPtr ) );
   
  @@ -296,11 +290,11 @@
   				}
   				else
   				{
  -					NextBlock* p = reinterpret_cast<NextBlock*>(pRunPtr);
  +					NextBlock* const    p = reinterpret_cast<NextBlock*>(pRunPtr);
   
   					assert( p->isValidFor( this->m_blockSize ) );
   
  -					pRunPtr = this->m_objectBlock + p->next ;
  +					pRunPtr = this->m_objectBlock + p->next;
   				}
   			}
   
  @@ -309,11 +303,12 @@
   	}
   
   
  -	size_type		m_firstFreeBlock;
  -
  -	size_type		m_nextFreeBlock;
  +    // Data members...
  +	size_type   m_firstFreeBlock;
   
  +	size_type	m_nextFreeBlock;
   };
  +
   
   
   XALAN_CPP_NAMESPACE_END
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org