The THeapWalk class provides behaviour for walking the heap. This class is pure virtual and developers must provide a derived class in order to use it.
A heap can be checked to make sure that its allocated and free cells are in a consistent state and that the heap is not corrupt.
The THeapWalk class provides the behaviour for doing this. This class is pure virtual and developers must provide a derived class in order to use it.
Simply construct a THeapWalk derived object, passing a reference to the heap which is to be checked in its constructor. Walking the heap is initiated by calling Walk() . This function follows the list of allocated and free cells in the heap. The function calls the virtual function Info() for every good cell it finds, passing the cell's address and length.
Info() is a pure virtual function and a derived class must provide an implementation for it.
Walk() terminates when it has successfully followed the entire list of free and allocated cells or until it finds the first bad cell.
As a minimum, a class derived from THeapWalk might be:
class TMyClass : public THeapWalk {
public : TMyClass(RHeap& aHeap); void Info(TCellType aType,TAny *aBase,TInt aLength); }
where the constructor would be implemented as:
TMyClass::TMyClass(RHeap& aHeap) : THeapWalk(aHeap) {}
Typically, the Info() function might consist of a switch statement based on the value of aType :
TMyClass::Info(TCellType aType,TAny *aBase,TInt aLength) { switch(aType) { case EGoodAllocatedCell: ... break; case EGoodFreeCell: ... break; case EBadFreeCellAddress: ... break; default: ... } }
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.