// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
-#ifdef __GNUG__
- #pragma implementation "garbagec.h"
-#endif
-
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
inline static GCItem& node_to_item( wxNode* pNode )
{
- return *( (GCItem*)(pNode->Data()) );
+ return *( (GCItem*)(pNode->GetData()) );
}
GarbageCollector::~GarbageCollector()
void GarbageCollector::DestroyItemList( wxList& lst )
{
- wxNode* pNode = lst.First();
+ wxNode* pNode = lst.GetFirst();
while( pNode )
{
delete &node_to_item( pNode );
- pNode = pNode->Next();
+ pNode = pNode->GetNext();
}
lst.Clear();
wxNode* GarbageCollector::FindItemNode( void* pForObj )
{
- wxNode* pNode = mAllNodes.First();
+ wxNode* pNode = mAllNodes.GetFirst();
while( pNode )
{
return pNode;
- pNode = pNode->Next();
+ pNode = pNode->GetNext();
}
- int avoidCompilerWarning = 0;
- wxASSERT(avoidCompilerWarning); // DBG:: item should be present
-
- return 0;
+ return NULL;
}
wxNode* GarbageCollector::FindReferenceFreeItemNode()
{
- wxNode* pNode = mAllNodes.First();
+ wxNode* pNode = mAllNodes.GetFirst();
while( pNode )
{
- if ( node_to_item( pNode ).mRefs.Number() == 0 )
+ if ( node_to_item( pNode ).mRefs.GetCount() == 0 )
return pNode;
- pNode = pNode->Next();
+ pNode = pNode->GetNext();
}
return 0;
void GarbageCollector::RemoveReferencesToNode( wxNode* pItemNode )
{
- wxNode* pNode = mAllNodes.First();
+ wxNode* pNode = mAllNodes.GetFirst();
while( pNode )
{
wxList& refLst = node_to_item( pNode ).mRefs;
- wxNode* pRefNode = refLst.First();
+ wxNode* pRefNode = refLst.GetFirst();
while( pRefNode )
{
- if ( pRefNode->Data() == (wxObject*)pItemNode )
+ if ( pRefNode->GetData() == (wxObject*)pItemNode )
{
- wxNode* pNext = pRefNode->Next();
+ wxNode* pNext = pRefNode->GetNext();
refLst.DeleteNode( pRefNode );
continue;
}
- else pRefNode = pRefNode->Next();
+ else pRefNode = pRefNode->GetNext();
}
- pNode = pNode->Next();
+ pNode = pNode->GetNext();
}
}
void GarbageCollector::ResolveReferences()
{
- wxNode* pNode = mAllNodes.First();
+ wxNode* pNode = mAllNodes.GetFirst();
while( pNode )
{
GCItem& item = node_to_item( pNode );
- wxNode* pRefNode = item.mRefs.First();
+ wxNode* pRefNode = item.mRefs.GetFirst();
while( pRefNode )
{
- pRefNode->SetData( (wxObject*) FindItemNode( (void*)pRefNode->Data() ) );
+ pRefNode->SetData( (wxObject*) FindItemNode( (void*)pRefNode->GetData() ) );
- pRefNode = pRefNode->Next();
+ pRefNode = pRefNode->GetNext();
}
- pNode = pNode->Next();
+ pNode = pNode->GetNext();
}
}
-void GarbageCollector::AddObject( void* pObj, int refCnt )
+void GarbageCollector::AddObject( void* pObj, int WXUNUSED(refCnt) )
{
// FOR NOW:: initial ref-count is not used
// append it to the list, where items are contained
// in the increasing order of dependencies
- mRegularLst.Append( pItemNode->Data() );
+ mRegularLst.Append( pItemNode->GetData() );
mAllNodes.DeleteNode( pItemNode );
// otherwise, what is left - all nodes, which
// are involved into cycled chains (rings)
- wxNode* pNode = mAllNodes.First();
+ wxNode* pNode = mAllNodes.GetFirst();
while( pNode )
{
- mCycledLst.Append( pNode->Data() );
+ mCycledLst.Append( pNode->GetData() );
- pNode = pNode->Next();
+ pNode = pNode->GetNext();
}
+ mAllNodes.Clear();
break;
}
void GarbageCollector::Reset()
{
DestroyItemList( mAllNodes );
-
- mRegularLst.Clear();
- mCycledLst.Clear();
+ DestroyItemList( mRegularLst );
+ DestroyItemList( mCycledLst );
}