Changeset - r4988:fdd36077b23c
[Not reviewed]
master
0 1 0
tron - 18 years ago 2006-10-28 12:32:55
tron@openttd.org
(svn r6991) Remove an unnecessary const_cast<> and incorrect comment (There is a difference between const FOO* and FOO* const)
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
yapf/fixedsizearray.hpp
Show inline comments
 
@@ -32,25 +32,25 @@ struct CFixedSizeArrayT {
 
	CFixedSizeArrayT()
 
	{
 
		// allocate block for header + items (don't construct items)
 
		m_items = (Titem*)(((int8*)malloc(ThdrSize + Tcapacity * sizeof(Titem))) + ThdrSize);
 
		SizeRef() = 0; // initial number of items
 
		RefCnt() = 1; // initial reference counter
 
	}
 

	
 
	/** Copy constructor. Preallocate space for items and header, then initialize header. */
 
	CFixedSizeArrayT(const CFixedSizeArrayT<Titem_, Tcapacity_>& src)
 
	{
 
		// share block (header + items) with the source array
 
		m_items = const_cast<Titem*>(src.m_items); // here we break the 'const' modifier
 
		m_items = src.m_items;
 
		RefCnt()++; // now we share block with the source
 
	}
 

	
 
	/** destroy remaining items and free the memory block */
 
	~CFixedSizeArrayT()
 
	{
 
		// release one reference to the shared block
 
		if ((--RefCnt()) > 0) return; // and return if there is still some owner
 

	
 
		// walk through all allocated items backward and destroy them
 
		for (Titem* pItem = &m_items[Size() - 1]; pItem >= m_items; pItem--) {
 
			pItem->~Titem_();
0 comments (0 inline, 0 general)