Location:
e32std.h
Link against: euser.lib
THeapWalk
Supported from 5.0
Provides the behaviour for walking through the lists of allocated and free cells of a heap to check that the heap is in a consistent state and is not corrupted.
The class is pure virtual and is not intended to be instantiated.
Instead, a derived class must be constructed which provides an implementation
for the Info()
pure virtual function.
Writing derived classes:
The THeapWalk
class provides most of the effort for
walking the heap. To use it, a derived class must be built which provides an
implementation for the Info()
function.
Info()
is called by the Walk()
function
for every good allocated cell and every good free cell on the heap together
with the address and length of these cells. The derived class can use this
information as it sees fit.
In addition, Info()
is called when Walk()
detects a free cell or an allocated cell which it considers to be bad. In this
event, this call to Info()
is the last one before
Walk()
itself terminates.
Defined in THeapWalk
:
EBadAllocatedCellAddress
, EBadAllocatedCellSize
, EBadFreeCellAddress
, EGoodAllocatedCell
, EGoodFreeCell
, Info()
, SetValue()
, TCellType
, THeapWalk()
, Value()
, Walk()
THeapWalk(const RHeap& aHeap);
Constructs this object taking a reference to the specified heap which is to be checked.
|
TInt Walk();
Walks through the entire heap.
The function walks through the list of allocated cells and the list of free cells checking that the addresses and lengths of both allocated cells and free cells are consistent.
The function terminates when it has successfully walked the entire heap or when it has found an error such as a bad cell pointer, a bad cell length or a cell which appears to overlap another cell.
|
virtual void Info(TCellType aType,TAny* aBase,TInt aLength)=0;
Gets information for every good allocated cell and every good free
cell on the heap together with the address and length of these cells. This
function is called by the Walk()
function.
It is also called when Walk()
detects a free cell or
an allocated cell which it considers to be bad. In this event, this is the last
call to Info()
before Walk()
itself
terminates.
|
protected: TInt Value() const;
Returns the value currently held by this object. The class contains a private data member for holding this.
The heap walker function Walk()
returns the current
value when it terminates, either after successfully walking the entire heap or
prematurely when it discovers a bad allocated or free cell.
The value can be set using the SetValue()
member
function.
No specific meaning is assigned to this value by this class; a
derived class is free to use it as it wishes, for example, to keep a count of
the number of cells found. It is likely that this function will be useful to
the derived class implementation of Info()
.
|
protected: void SetValue(TInt aValue);
Sets a value into this object. The class contains a private data member for holding this value.
The heap walker function Walk()
returns the current value
when it terminates, either after successfully walking the entire heap or
prematurely when it discovers a bad allocated or free cell.
No specific meaning is assigned to this value by this class; a derived
class is free to use it as it wishes, for example, to keep a count of the
number of cells found. It is likely that this function will be useful to the
derived class implementation of Info()
.
|
TCellType
Describes the type and state of cell found on the heap by
Walk()
. Information of this type is passed to each call of the
Info()
function by the heap walker,
Walk()
.
|