Location:
e32cmn.h
Link against: euser.lib
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.
MAllocator
- No description.
RAllocator
- Base class for heaps
RHeap
- Represents the default implementation for a heap
Defined in RHeap
:
Alloc()
, AllocLen()
, AllocSize()
, Available()
, Base()
, Compress()
, EAllocCellSize
, ECellAlignment
, EFreeCellSize
, Extension_()
, FindFollowingFreeCell()
, Free()
, GetAddress()
, RHeap()
, ReAlloc()
, Reset()
, SCell
, SDebugCell
, SetBrk()
, Size()
, anonymous
, anonymous
, anonymous
, iAlign
, iAllocCount
, iBase
, iChunkHandle
, iFailAllocCount
, iFailRate
, iFailType
, iFailed
, iFree
, iGrowBy
, iLock
, iMaxLength
, iMinCell
, iMinLength
, iNestingLevel
, iOffset
, iPageSize
, iRand
, iTestData
, iTop
, operator delete()
Inherited from RAllocator
:
AllocL()
,
AllocLC()
,
AllocZ()
,
AllocZL()
,
Check()
,
Close()
,
Count()
,
EAllowMoveOnShrink
,
ECheck
,
ECopyDebugInfo
,
ECount
,
EDeterministic
,
EFailNext
,
EFixedSize
,
EKernel
,
EMarkEnd
,
EMarkStart
,
EMaxHandles
,
ENeverMove
,
ENone
,
ERandom
,
EReset
,
ESetFail
,
ESingleThreaded
,
ETrueRandom
,
EUser
,
FreeZ()
,
Open()
,
ReAllocL()
,
SCheckInfo
,
TAllocDebugOp
,
TAllocFail
,
TDbgHeapType
,
TFlags
,
TReAllocMode
,
__DbgMarkCheck()
,
__DbgMarkEnd()
,
__DbgMarkStart()
,
__DbgSetAllocFail()
,
iAccessCount
,
iCellCount
,
iFlags
,
iHandleCount
,
iHandles
,
iTotalAllocSize
virtual UIMPORT_C TAny *Alloc(TInt aSize);
Allocates a cell of the specified size from the heap.
If there is insufficient memory available on the heap from which to allocate a cell of the required size, the function returns NULL.
The cell is aligned according to the alignment value specified at construction, or the default alignment value, if an explict value was not specified.
The resulting size of the allocated cell may be rounded up to a value greater than aSize, but is guaranteed to be not less than aSize.
|
|
|
virtual UIMPORT_C void Free(TAny *aPtr);
Frees the specified cell and returns it to the heap.
|
|
virtual UIMPORT_C TAny *ReAlloc(TAny *aPtr, TInt aSize, TInt aMode=0);
Increases or decreases the size of an existing cell in the heap.
If the cell is being decreased in size, then it is guaranteed not to move, and the function returns the pointer originally passed in aCell. Note that the length of the cell will be the same if the difference between the old size and the new size is smaller than the minimum cell size.
If the cell is being increased in size, i.e. aSize is bigger than its current size, then the function tries to grow the cell in place. If successful, then the function returns the pointer originally passed in aCell. If unsuccessful, then:
1. if the cell cannot be moved, i.e. aMode has the ENeverMove bit set, then the function returns NULL. 2. if the cell can be moved, i.e. aMode does not have the ENeverMove bit set, then the function tries to allocate a new replacement cell, and, if successful, returns a pointer to the new cell; if unsuccessful, it returns NULL.
Note that in debug mode, the function returns NULL if the cell cannot be grown in place, regardless of whether the ENeverMove bit is set.
If the reallocated cell is at a different location from the original cell, then the content of the original cell is copied to the reallocated cell.
If the supplied pointer, aCell is NULL, then the function attempts to allocate a new cell, but only if the cell can be moved, i.e. aMode does not have the ENeverMove bit set.
Note the following general points:
1. If reallocation fails, the content of the original cell is preserved.
2. The resulting size of the re-allocated cell may be rounded up to a value greater than aSize, but is guaranteed to be not less than aSize.
|
|
|
virtual UIMPORT_C TInt AllocLen(const TAny *aCell) const;
Gets the length of the available space in the specified allocated cell.
|
|
|
virtual UIMPORT_C TInt Compress();
Compresses the heap.
The function frees excess committed space from the top of the heap. The size of the heap is never reduced below the minimum size specified during creation of the heap.
|
virtual UIMPORT_C TInt AllocSize(TInt &aTotalAllocSize) const;
Gets the number of cells allocated on this heap, and the total space allocated to them.
|
|
virtual UIMPORT_C TInt Available(TInt &aBiggestBlock) const;
Gets the total free space currently available on the heap and the space available in the largest free block.
The space available represents the total space which can be allocated.
Note that compressing the heap may reduce the total free space available and the space available in the largest free block.
|
|
protected: virtual UIMPORT_C TInt Extension_(TUint aExtensionId, TAny *&a0, TAny *a1);
|
|
inline void operator delete(TAny *aPtr, TAny *aBase);
Called if constructor issued by operator new(TUint aSize, TAny* aBase)
throws exception. This is dummy as corresponding new operator does not allocate memory.
|
inline TUint8 *Base() const;
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.
|
inline TInt Size() const;
Gets the current size of the heap.
This is the total number of bytes committed by the host chunk.
Note that this value is always greater than the total space available across all allocated cells.
|
protected: inline void FindFollowingFreeCell(SCell *aCell, SCell *&pPrev, SCell *&aNext);
|
protected: UIMPORT_C SCell *GetAddress(const TAny *aCell) const;
|
|
struct SCell;
The structure of a heap cell header for a heap cell on the free list.
Defined in RHeap::SCell
:
len
, next
len
TInt len;
The length of the cell, which includes the length of this header.
next
SCell * next;
A pointer to the next cell in the free list.
struct SDebugCell;
The structure of a heap cell header for an allocated heap cell in a debug build.
Defined in RHeap::SDebugCell
:
allocCount
, len
, nestingLevel
len
TInt len;
The length of the cell, which includes the length of this header.
nestingLevel
TInt nestingLevel;
The nested level.
allocCount
TInt allocCount;
The cumulative number of allocated cells
protected: TAny * iTestData;