diff -r 000000000000 -r 89d6a7a84779 Symbian3/SDK/Source/GUID-8E363123-A85E-521C-BC10-96C59130E45C.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/SDK/Source/GUID-8E363123-A85E-521C-BC10-96C59130E45C.dita Thu Jan 21 18:18:20 2010 +0000 @@ -0,0 +1,61 @@ + + + + + +How +to walk the heapThe 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: + ... + } + } +
\ No newline at end of file