RHeap Class Reference

class RHeap : public RAllocator

Represents the default implementation for a heap.

The default implementation uses an address-ordered first fit type algorithm.

The heap itself is contained in a chunk and may be the only occupant of the chunk or may share the chunk with the program stack.

The class contains member functions for allocating, adjusting, freeing individual cells and generally managing the heap.

The class is not a handle in the same sense that RChunk is a handle; i.e. there is no Kernel object which corresponds to the heap.

Inherits from

Public Member Functions
RHeap(TInt, TInt, TBool)
RHeap(TInt, TInt, TInt, TInt, TInt, TInt, TBool)
TInt Align(TInt)
const TAny *Align(const TAny *)
UIMPORT_C TAny *Alloc(TInt)
UIMPORT_C TIntAllocLen(const TAny *)
UIMPORT_C TIntAllocSize(TInt &)
UIMPORT_C TIntAvailable(TInt &)
TUint8 *Base()
TInt ChunkHandle()
UIMPORT_C TIntCompress()
UIMPORT_C TIntDebugFunction(TInt, TAny *, TAny *)
UIMPORT_C voidFree(TAny *)
TBool IsLastCell(const SCell *)
voidLock()
TInt MaxLength()
UIMPORT_C TAny *ReAlloc(TAny *, TInt, TInt)
UIMPORT_C voidReset()
TInt Size()
voidUnlock()
voidoperator delete(TAny *, TAny *)
UIMPORT_C TAny *operator new(TUint, TAny *)
Protected Member Functions
RHeap()
voidCheckCell(const SCell *)
TBool CheckForSimulatedAllocFail()
SCell *DoAlloc(TInt, SCell *&)
TInt DoCheckHeap(SCheckInfo *)
TInt DoCountAllocFree(TInt &)
voidDoFree(SCell *)
TUint32 DoMarkEnd(TInt)
voidDoMarkStart()
voidDoSetAllocFail(TAllocFail, TInt)
voidDoSetAllocFail(TAllocFail, TInt, TUint)
UIMPORT_C TIntExtension_(TUint, TAny *&, TAny *)
voidFindFollowingFreeCell(SCell *, SCell *&, SCell *&)
UIMPORT_C SCell *GetAddress(const TAny *)
voidInitialise()
TAny *ReAllocImpl(TAny *, TInt, TInt)
TInt Reduce(SCell *)
TInt SetBrk(TInt)
TInt TryToGrowCell(SCell *, SCell *, SCell *, TInt)
TInt TryToGrowHeap(TInt, SCell *)
voidWalk(TWalkFunc, TAny *)
voidWalkCheckCell(TAny *, TCellType, TAny *, TInt)
Inherited Functions
RAllocator::AllocL(TInt)
RAllocator::AllocLC(TInt)
RAllocator::AllocZ(TInt)
RAllocator::AllocZL(TInt)
RAllocator::Check()const
RAllocator::Close()
RAllocator::Count()const
RAllocator::Count(TInt &)const
RAllocator::DoClose()
RAllocator::FreeZ(TAny *&)
RAllocator::Open()
RAllocator::RAllocator()
RAllocator::ReAllocL(TAny *,TInt,TInt)
RAllocator::__DbgCheckFailure()
RAllocator::__DbgMarkCheck(TBool,TInt,const TDesC8 &,TInt)
RAllocator::__DbgMarkCheck(TBool,TInt,const TUint8 *,TInt)
RAllocator::__DbgMarkEnd(TInt)
RAllocator::__DbgMarkStart()
RAllocator::__DbgSetAllocFail(TAllocFail,TInt)
RAllocator::__DbgSetBurstAllocFail(TAllocFail,TUint,TUint)
Public Member Enumerations
enumTCellType {
EGoodAllocatedCell, EGoodFreeCell, EBadAllocatedCellSize, EBadAllocatedCellAddress, EBadFreeCellAddress, EBadFreeCellSize
}
enumTDebugHeapId { EUser = 0, EKernel = 1 }
enumTDebugOp { EWalk = 128 }
enumTDefaultShrinkRatios { EShrinkRatio1 = 256, EShrinkRatioDflt = 512 }
Inherited Enumerations
RAllocator:@13
RAllocator:TAllocDebugOp
RAllocator:TAllocFail
RAllocator:TDbgHeapType
RAllocator:TFlags
RAllocator:TReAllocMode
Public Member Type Definitions
typedefvoid(* TWalkFunc
Protected Attributes
TInt iAlign
TInt iAllocCount
TUint8 *iBase
TInt iChunkHandle
TInt iFailAllocCount
TInt iFailRate
TAllocFail iFailType
TBool iFailed
SCell iFree
TInt iGrowBy
RFastLock iLock
TInt iMaxLength
TInt iMinCell
TInt iMinLength
TInt iNestingLevel
TInt iOffset
TInt iPageSize
TInt iRand
TAny *iTestData
TUint8 *iTop
Inherited Attributes
RAllocator::iAccessCount
RAllocator::iCellCount
RAllocator::iFlags
RAllocator::iHandleCount
RAllocator::iHandles
RAllocator::iTotalAllocSize

Constructor & Destructor Documentation

RHeap(TInt, TInt, TBool)

UIMPORT_CRHeap(TIntaMaxLength,
TIntaAlign = 0,
TBoolaSingleThread = ETrue
)

Parameters

TInt aMaxLength
TInt aAlign = 0
TBool aSingleThread = ETrue

RHeap(TInt, TInt, TInt, TInt, TInt, TInt, TBool)

UIMPORT_CRHeap(TIntaChunkHandle,
TIntaOffset,
TIntaMinLength,
TIntaMaxLength,
TIntaGrowBy,
TIntaAlign = 0,
TBoolaSingleThread = EFalse
)

Parameters

TInt aChunkHandle
TInt aOffset
TInt aMinLength
TInt aMaxLength
TInt aGrowBy
TInt aAlign = 0
TBool aSingleThread = EFalse

RHeap()

RHeap()[protected, inline]

Member Functions Documentation

Align(TInt)

TInt Align(TInta)const [inline]

Parameters

TInt a

Align(const TAny *)

const TAny *Align(const TAny *a)const [inline]

Parameters

const TAny * a

Alloc(TInt)

UIMPORT_C TAny *Alloc(TIntaSize)[virtual]

Parameters

TInt aSize

AllocLen(const TAny *)

UIMPORT_C TIntAllocLen(const TAny *aCell)const [virtual]

Parameters

const TAny * aCell

AllocSize(TInt &)

UIMPORT_C TIntAllocSize(TInt &aTotalAllocSize)const [virtual]

Parameters

TInt & aTotalAllocSize

Available(TInt &)

UIMPORT_C TIntAvailable(TInt &aBiggestBlock)const [virtual]

Parameters

TInt & aBiggestBlock

Base()

TUint8 *Base()const [inline]

Gets a pointer to the start of the heap.

Note that because of the small space overhead incurred by all allocated cells, no cell will have the same address as that returned by this function.

A pointer to the base of the heap.

CheckCell(const SCell *)

voidCheckCell(const SCell *aCell)const [protected]

Parameters

const SCell * aCell

CheckForSimulatedAllocFail()

TBool CheckForSimulatedAllocFail()[protected]

ChunkHandle()

TInt ChunkHandle()const [inline]

Compress()

UIMPORT_C TIntCompress()[virtual]

DebugFunction(TInt, TAny *, TAny *)

UIMPORT_C TIntDebugFunction(TIntaFunc,
TAny *a1 = NULL,
TAny *a2 = NULL
)[virtual]

Parameters

TInt aFunc
TAny * a1 = NULL
TAny * a2 = NULL

DoAlloc(TInt, SCell *&)

SCell *DoAlloc(TIntaSize,
SCell *&aLastFree
)[protected]

Parameters

TInt aSize
SCell *& aLastFree

DoCheckHeap(SCheckInfo *)

TInt DoCheckHeap(SCheckInfo *aInfo)[protected]

Parameters

SCheckInfo * aInfo

DoCountAllocFree(TInt &)

TInt DoCountAllocFree(TInt &aFree)[protected]

Parameters

TInt & aFree

DoFree(SCell *)

voidDoFree(SCell *pC)[protected]

Parameters

SCell * pC

DoMarkEnd(TInt)

TUint32 DoMarkEnd(TIntaExpected)[protected]

Parameters

TInt aExpected

DoMarkStart()

voidDoMarkStart()[protected]

DoSetAllocFail(TAllocFail, TInt)

voidDoSetAllocFail(TAllocFailaType,
TIntaRate
)[protected]

Parameters

TAllocFail aType
TInt aRate

DoSetAllocFail(TAllocFail, TInt, TUint)

voidDoSetAllocFail(TAllocFailaType,
TIntaRate,
TUintaBurst
)[protected]

Parameters

TAllocFail aType
TInt aRate
TUint aBurst

Extension_(TUint, TAny *&, TAny *)

UIMPORT_C TIntExtension_(TUintaExtensionId,
TAny *&a0,
TAny *a1
)[protected, virtual]

Parameters

TUint aExtensionId
TAny *& a0
TAny * a1

FindFollowingFreeCell(SCell *, SCell *&, SCell *&)

voidFindFollowingFreeCell(SCell *aCell,
SCell *&pPrev,
SCell *&aNext
)[protected, inline]

Parameters

SCell * aCell
SCell *& pPrev
SCell *& aNext

Free(TAny *)

UIMPORT_C voidFree(TAny *aPtr)[virtual]

Parameters

TAny * aPtr

GetAddress(const TAny *)

UIMPORT_C SCell *GetAddress(const TAny *aCell)const [protected]

Parameters

const TAny * aCell

Initialise()

voidInitialise()[protected]

IsLastCell(const SCell *)

TBool IsLastCell(const SCell *aCell)const [inline]

Parameters

const SCell * aCell

Lock()

voidLock()const [inline]

MaxLength()

TInt MaxLength()const [inline]

The maximum length to which the heap can grow.

ReAlloc(TAny *, TInt, TInt)

UIMPORT_C TAny *ReAlloc(TAny *aPtr,
TIntaSize,
TIntaMode = 0
)[virtual]

Parameters

TAny * aPtr
TInt aSize
TInt aMode = 0

ReAllocImpl(TAny *, TInt, TInt)

TAny *ReAllocImpl(TAny *aPtr,
TIntaSize,
TIntaMode
)[protected, inline]

Parameters

TAny * aPtr
TInt aSize
TInt aMode

Reduce(SCell *)

TInt Reduce(SCell *aCell)[protected]

Parameters

SCell * aCell

Reset()

UIMPORT_C voidReset()[virtual]

SetBrk(TInt)

TInt SetBrk(TIntaBrk)[protected, inline]

Parameters

TInt aBrk

Size()

TInt Size()const [inline]

Gets the current size of the heap.

This is the total number of bytes committed by the host chunk. It is the requested size rounded up by page size minus the size of RHeap object(116 bytes) minus the cell alignment overhead as shown:

Size = (Rounded committed size - Size of RHeap - Cell Alignment Overhead).

The cell alignment overhead varies between release builds and debug builds.

Note that this value is always greater than the total space available across all allocated cells.

The size of the heap.

Rheap::Available( )

TryToGrowCell(SCell *, SCell *, SCell *, TInt)

TInt TryToGrowCell(SCell *pC,
SCell *pP,
SCell *pE,
TIntaSize
)[protected]

Parameters

SCell * pC
SCell * pP
SCell * pE
TInt aSize

TryToGrowHeap(TInt, SCell *)

TInt TryToGrowHeap(TIntaSize,
SCell *aLastFree
)[protected]

Parameters

TInt aSize
SCell * aLastFree

Unlock()

voidUnlock()const [inline]

Walk(TWalkFunc, TAny *)

voidWalk(TWalkFuncaFunc,
TAny *aPtr
)[protected]

Parameters

TWalkFunc aFunc
TAny * aPtr

WalkCheckCell(TAny *, TCellType, TAny *, TInt)

voidWalkCheckCell(TAny *aPtr,
TCellTypeaType,
TAny *aCell,
TIntaLen
)[protected, static]

Parameters

TAny * aPtr
TCellType aType
TAny * aCell
TInt aLen

operator delete(TAny *, TAny *)

voidoperator delete(TAny *aPtr,
TAny *aBase
)[inline]

Called if constructor issued by operator new(TUint aSize, TAny* aBase) throws exception. This is dummy as corresponding new operator does not allocate memory.

Parameters

TAny * aPtr
TAny * aBase

operator new(TUint, TAny *)

UIMPORT_C TAny *operator new(TUintaSize,
TAny *aBase
)

Parameters

TUint aSize
TAny * aBase

Member Enumerations Documentation

Enum TCellType

Enumerators

EGoodAllocatedCell
EGoodFreeCell
EBadAllocatedCellSize
EBadAllocatedCellAddress
EBadFreeCellAddress
EBadFreeCellSize

Enum TDebugHeapId

Enumerators

EUser = 0

The heap is a user heap.

EKernel = 1

The heap is the Kernel heap.

Enum TDebugOp

Enumerators

EWalk = 128

Enum TDefaultShrinkRatios

Enumerators

EShrinkRatio1 = 256
EShrinkRatioDflt = 512

Member Type Definitions Documentation

Typedef TWalkFunc

typedef void(*TWalkFunc

Member Data Documentation

TInt iAlign

TInt iAlign[protected]

TInt iAllocCount

TInt iAllocCount[protected]

TUint8 * iBase

TUint8 *iBase[protected]

TInt iChunkHandle

TInt iChunkHandle[protected]

TInt iFailAllocCount

TInt iFailAllocCount[protected]

TInt iFailRate

TInt iFailRate[protected]

TAllocFail iFailType

TAllocFail iFailType[protected]

TBool iFailed

TBool iFailed[protected]

SCell iFree

SCell iFree[protected]

TInt iGrowBy

TInt iGrowBy[protected]

RFastLock iLock

RFastLock iLock[protected]

TInt iMaxLength

TInt iMaxLength[protected]

TInt iMinCell

TInt iMinCell[protected]

TInt iMinLength

TInt iMinLength[protected]

TInt iNestingLevel

TInt iNestingLevel[protected]

TInt iOffset

TInt iOffset[protected]

TInt iPageSize

TInt iPageSize[protected]

TInt iRand

TInt iRand[protected]

TAny * iTestData

TAny *iTestData[protected]

TUint8 * iTop

TUint8 *iTop[protected]