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.
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 TInt | AllocLen(const TAny *) |
UIMPORT_C TInt | AllocSize(TInt &) |
UIMPORT_C TInt | Available(TInt &) |
TUint8 * | Base() |
TInt | ChunkHandle() |
UIMPORT_C TInt | Compress() |
UIMPORT_C TInt | DebugFunction(TInt, TAny *, TAny *) |
UIMPORT_C void | Free(TAny *) |
TBool | IsLastCell(const SCell *) |
void | Lock() |
TInt | MaxLength() |
UIMPORT_C TAny * | ReAlloc(TAny *, TInt, TInt) |
UIMPORT_C void | Reset() |
TInt | Size() |
void | Unlock() |
void | operator delete(TAny *, TAny *) |
UIMPORT_C TAny * | operator new(TUint, TAny *) |
Protected Member Functions | |
---|---|
RHeap() | |
void | CheckCell(const SCell *) |
TBool | CheckForSimulatedAllocFail() |
SCell * | DoAlloc(TInt, SCell *&) |
TInt | DoCheckHeap(SCheckInfo *) |
TInt | DoCountAllocFree(TInt &) |
void | DoFree(SCell *) |
TUint32 | DoMarkEnd(TInt) |
void | DoMarkStart() |
void | DoSetAllocFail(TAllocFail, TInt) |
void | DoSetAllocFail(TAllocFail, TInt, TUint) |
UIMPORT_C TInt | Extension_(TUint, TAny *&, TAny *) |
void | FindFollowingFreeCell(SCell *, SCell *&, SCell *&) |
UIMPORT_C SCell * | GetAddress(const TAny *) |
void | Initialise() |
TAny * | ReAllocImpl(TAny *, TInt, TInt) |
TInt | Reduce(SCell *) |
TInt | SetBrk(TInt) |
TInt | TryToGrowCell(SCell *, SCell *, SCell *, TInt) |
TInt | TryToGrowHeap(TInt, SCell *) |
void | Walk(TWalkFunc, TAny *) |
void | WalkCheckCell(TAny *, TCellType, TAny *, TInt) |
Public Member Enumerations | |
---|---|
enum | TCellType { EGoodAllocatedCell, EGoodFreeCell, EBadAllocatedCellSize, EBadAllocatedCellAddress, EBadFreeCellAddress, EBadFreeCellSize } |
enum | TDebugHeapId { EUser = 0, EKernel = 1 } |
enum | TDebugOp { EWalk = 128 } |
enum | TDefaultShrinkRatios { EShrinkRatio1 = 256, EShrinkRatioDflt = 512 } |
Inherited Enumerations | |
---|---|
RAllocator:@13 | |
RAllocator:TAllocDebugOp | |
RAllocator:TAllocFail | |
RAllocator:TDbgHeapType | |
RAllocator:TFlags | |
RAllocator:TReAllocMode |
Public Member Type Definitions | |
---|---|
typedef | void(* TWalkFunc |
Inherited Attributes | |
---|---|
RAllocator::iAccessCount | |
RAllocator::iCellCount | |
RAllocator::iFlags | |
RAllocator::iHandleCount | |
RAllocator::iHandles | |
RAllocator::iTotalAllocSize |
UIMPORT_C | RHeap | ( | TInt | aMaxLength, |
TInt | aAlign = 0, | |||
TBool | aSingleThread = ETrue | |||
) |
UIMPORT_C | RHeap | ( | TInt | aChunkHandle, |
TInt | aOffset, | |||
TInt | aMinLength, | |||
TInt | aMaxLength, | |||
TInt | aGrowBy, | |||
TInt | aAlign = 0, | |||
TBool | aSingleThread = EFalse | |||
) |
UIMPORT_C TInt | AllocLen | ( | const TAny * | aCell | ) | const [virtual] |
const TAny * aCell |
UIMPORT_C TInt | AllocSize | ( | TInt & | aTotalAllocSize | ) | const [virtual] |
TInt & aTotalAllocSize |
UIMPORT_C TInt | Available | ( | TInt & | aBiggestBlock | ) | const [virtual] |
TInt & aBiggestBlock |
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.
void | CheckCell | ( | const SCell * | aCell | ) | const [protected] |
const SCell * aCell |
UIMPORT_C TInt | DebugFunction | ( | TInt | aFunc, |
TAny * | a1 = NULL, | |||
TAny * | a2 = NULL | |||
) | [virtual] |
TInt | DoCheckHeap | ( | SCheckInfo * | aInfo | ) | [protected] |
SCheckInfo * aInfo |
void | DoSetAllocFail | ( | TAllocFail | aType, |
TInt | aRate | |||
) | [protected] |
TAllocFail aType | |
TInt aRate |
void | DoSetAllocFail | ( | TAllocFail | aType, |
TInt | aRate, | |||
TUint | aBurst | |||
) | [protected] |
TAllocFail aType | |
TInt aRate | |
TUint aBurst |
UIMPORT_C TInt | Extension_ | ( | TUint | aExtensionId, |
TAny *& | a0, | |||
TAny * | a1 | |||
) | [protected, virtual] |
void | FindFollowingFreeCell | ( | SCell * | aCell, |
SCell *& | pPrev, | |||
SCell *& | aNext | |||
) | [protected, inline] |
UIMPORT_C SCell * | GetAddress | ( | const TAny * | aCell | ) | const [protected] |
const TAny * aCell |
TBool | IsLastCell | ( | const SCell * | aCell | ) | const [inline] |
const SCell * aCell |
TAny * | ReAllocImpl | ( | TAny * | aPtr, |
TInt | aSize, | |||
TInt | aMode | |||
) | [protected, inline] |
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( )
TInt | TryToGrowCell | ( | SCell * | pC, |
SCell * | pP, | |||
SCell * | pE, | |||
TInt | aSize | |||
) | [protected] |
void | WalkCheckCell | ( | TAny * | aPtr, |
TCellType | aType, | |||
TAny * | aCell, | |||
TInt | aLen | |||
) | [protected, static] |
void | operator 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.
EGoodAllocatedCell | |
EGoodFreeCell | |
EBadAllocatedCellSize | |
EBadAllocatedCellAddress | |
EBadFreeCellAddress | |
EBadFreeCellSize |
EUser = 0 |
The heap is a user heap. |
EKernel = 1 |
The heap is the Kernel heap. |