|
Original Symbian headers
Selected EUSER, Window Server, networking, graphics and device declarations
|
Base class for heaps. More...
#include <e32cmn.h>
Classes | |
| struct | SCheckInfo |
| struct | SRAllocatorBurstFail |
Public Types | |
| enum | TAllocFail { ERandom , ETrueRandom , EDeterministic , ENone , EFailNext , EReset , EBurstRandom , EBurstTrueRandom , EBurstDeterministic , EBurstFailNext , ECheckFailure } |
| A set of heap allocation failure flags. More... | |
| enum | TDbgHeapType { EUser , EKernel } |
| Heap debug checking type flag. More... | |
| enum | TAllocDebugOp { ECount , EMarkStart , EMarkEnd , ECheck , ESetFail , ECopyDebugInfo , ESetBurstFail , EGetFail , EGetSize =48 , EGetMaxLength , EGetBase , EAlignInteger , EAlignAddr } |
| enum | TReAllocMode { ENeverMove =1 , EAllowMoveOnShrink =2 } |
| Flags controlling reallocation. More... | |
| enum | TFlags { ESingleThreaded =1 , EFixedSize =2 , ETraceAllocs =4 , EMonitorMemory =8 } |
| enum | { EMaxHandles =32 } |
Public Member Functions | |
| RAllocator () | |
| IMPORT_C TInt | Open () |
| Opens this heap for shared access. | |
| IMPORT_C void | Close () |
| Closes this shared heap. | |
| IMPORT_C TAny * | AllocZ (TInt aSize) |
| Allocates a cell of specified size from the heap, and clears it to binary zeroes. | |
| IMPORT_C TAny * | AllocZL (TInt aSize) |
| Allocates a cell of specified size from the heap, clears it to binary zeroes, and leaves if there is insufficient memory in the heap. | |
| IMPORT_C TAny * | AllocL (TInt aSize) |
| Allocates a cell of specified size from the heap, and leaves if there is insufficient memory in the heap. | |
| IMPORT_C TAny * | AllocLC (TInt aSize) |
| Allocates a cell of specified size from the heap, and, if successful, places a pointer to the cell onto the cleanup stack. | |
| IMPORT_C void | FreeZ (TAny *&aCell) |
| Frees the specified cell, returns it to the heap, and resets the pointer to NULL. | |
| IMPORT_C TAny * | ReAllocL (TAny *aCell, TInt aSize, TInt aMode=0) |
| Increases or decreases the size of an existing cell, and leaves if there is insufficient memory in the heap. | |
| IMPORT_C TInt | Count () const |
| Gets the total number of cells allocated on the heap. | |
| IMPORT_C TInt | Count (TInt &aFreeCount) const |
| Gets the the total number of cells allocated, and the number of free cells, on the heap. | |
| UIMPORT_C void | Check () const |
| Checks the validity of the heap. | |
| UIMPORT_C void | __DbgMarkStart () |
| Marks the start of heap cell checking for this heap. | |
| UIMPORT_C TUint32 | __DbgMarkEnd (TInt aCount) |
| Marks the end of heap cell checking at the current nested level for this heap. | |
| UIMPORT_C TInt | __DbgMarkCheck (TBool aCountAll, TInt aCount, const TDesC8 &aFileName, TInt aLineNum) |
| Checks the current number of allocated heap cells for this heap. | |
| void | __DbgMarkCheck (TBool aCountAll, TInt aCount, const TUint8 *aFileName, TInt aLineNum) |
| UIMPORT_C void | __DbgSetAllocFail (TAllocFail aType, TInt aRate) |
| Simulates a heap allocation failure for this heap. | |
| UIMPORT_C TAllocFail | __DbgGetAllocFail () |
| UIMPORT_C void | __DbgSetBurstAllocFail (TAllocFail aType, TUint aRate, TUint aBurst) |
| Simulates a burst of heap allocation failures for this heap. | |
| UIMPORT_C TUint | __DbgCheckFailure () |
| Returns the number of heap allocation failures the current debug allocator fail function has caused so far. | |
| UIMPORT_C TInt | Size () const |
| UIMPORT_C TInt | MaxLength () const |
| UIMPORT_C TUint8 * | Base () const |
| UIMPORT_C TInt | Align (TInt a) const |
| UIMPORT_C TAny * | Align (TAny *a) const |
Public Member Functions inherited from MAllocator | |
| virtual TAny * | Alloc (TInt aSize)=0 |
| virtual void | Free (TAny *aPtr)=0 |
| virtual TAny * | ReAlloc (TAny *aPtr, TInt aSize, TInt aMode=0)=0 |
| virtual TInt | AllocLen (const TAny *aCell) const =0 |
| virtual TInt | Compress ()=0 |
| virtual void | Reset ()=0 |
| virtual TInt | AllocSize (TInt &aTotalAllocSize) const =0 |
| virtual TInt | Available (TInt &aBiggestBlock) const =0 |
| virtual TInt | DebugFunction (TInt aFunc, TAny *a1=NULL, TAny *a2=NULL)=0 |
Protected Member Functions | |
| virtual UIMPORT_C TInt | Extension_ (TUint aExtensionId, TAny *&a0, TAny *a1) |
| virtual IMPORT_C void | DoClose () |
Protected Attributes | |
| TInt | iAccessCount |
| TInt | iHandleCount |
| TInt * | iHandles |
| TUint32 | iFlags |
| TInt | iCellCount |
| TInt | iTotalAllocSize |
Base class for heaps.
A set of heap allocation failure flags.
This enumeration indicates how to simulate heap allocation failure.
| Enumerator | |
|---|---|
| ERandom | Attempts to allocate from this heap fail at a random rate; however, the interval pattern between failures is the same every time simulation is started. |
| ETrueRandom | Attempts to allocate from this heap fail at a random rate. The interval pattern between failures may be different every time the simulation is started. |
| EDeterministic | Attempts to allocate from this heap fail at a rate aRate; for example, if aRate is 3, allocation fails at every third attempt. |
| ENone | Cancels simulated heap allocation failure. |
| EFailNext | An allocation from this heap will fail after the next aRate - 1 allocation attempts. For example, if aRate = 1 then the next attempt to allocate from this heap will fail. |
| EReset | Cancels simulated heap allocation failure, and sets the nesting level for all allocated cells to zero. |
| EBurstRandom | aBurst allocations from this heap fail at a random rate; however, the interval pattern between failures is the same every time the simulation is started. |
| EBurstTrueRandom | aBurst allocations from this heap fail at a random rate. The interval pattern between failures may be different every time the simulation is started. |
| EBurstDeterministic | aBurst allocations from this heap fail at a rate aRate. For example, if aRate is 10 and aBurst is 2, then 2 allocations will fail at every tenth attempt. |
| EBurstFailNext | aBurst allocations from this heap will fail after the next aRate - 1 allocation attempts have occurred. For example, if aRate = 1 and aBurst = 3 then the next 3 attempts to allocate from this heap will fail. |
| ECheckFailure | Use this to determine how many times the current debug failure mode has failed so far.
|
| enum RAllocator::TFlags |
|
inline |
| UIMPORT_C TUint RAllocator::__DbgCheckFailure | ( | ) |
Returns the number of heap allocation failures the current debug allocator fail function has caused so far.
This is intended to only be used with fail types RAllocator::EFailNext, RAllocator::EBurstFailNext, RAllocator::EDeterministic and RAllocator::EBurstDeterministic. The return value is unreliable for all other fail types.
(generated from Symbian Developer Library)
| UIMPORT_C TAllocFail RAllocator::__DbgGetAllocFail | ( | ) |
| UIMPORT_C TInt RAllocator::__DbgMarkCheck | ( | TBool | aCountAll, |
| TInt | aCount, | ||
| const TDesC8 & | aFileName, | ||
| TInt | aLineNum | ||
| ) |
Checks the current number of allocated heap cells for this heap.
If aCountAll is true, the function checks that the total number of allocated cells on this heap is the same as aCount. If aCountAll is false, then the function checks that the number of allocated cells at the current nested level is the same as aCount.
If checking fails, the function raises a panic; information about the failure is put into the panic category; this takes the form:
ALLOC COUNT\rExpected aaa\rAllocated bbb\rLn: ccc ddddd
where
Note that the panic number is 1.
| aCountAll | If true, the function checks that the total number of allocated cells on this heap is the same as aCount. If false, the function checks that the number of allocated cells at the current nested level is the same as aCount. |
| aCount | The expected number of allocated cells. |
| aFileName | A filename; this is displayed as part of the panic category if the check fails. |
| aLineNum | A line number; this is displayed as part of the panic category if the check fails. |
(generated from Symbian Developer Library)
|
inline |
| UIMPORT_C TUint32 RAllocator::__DbgMarkEnd | ( | TInt | aCount | ) |
Marks the end of heap cell checking at the current nested level for this heap.
A call to this function should match an earlier call to __DbgMarkStart(). If there are more calls to this function than calls to __DbgMarkStart(), then this function raises a USER 51 panic.
The function checks that the number of heap cells allocated, at the current nested level, is aCount. The most common value for aCount is zero, reflecting the fact that most developers check that all memory allocated since a previous call to __DbgMarkStart() has been freed.
If the check fails, the function returns a pointer to the first orphaned heap cell.
| aCount | The number of allocated heap cells expected. |
(generated from Symbian Developer Library)
| UIMPORT_C void RAllocator::__DbgMarkStart | ( | ) |
Marks the start of heap cell checking for this heap.
If earlier calls to __DbgMarkStart() have been made, then this call to __DbgMarkStart() marks the start of a new nested level of heap cell checking.
Every call to __DbgMarkStart() should be matched by a later call to __DbgMarkEnd() to verify that the number of heap cells allocated, at the current nested level, is as expected. This expected number of heap cells is passed to __DbgMarkEnd() as a parameter; however, the most common expected number is zero, reflecting the fact that most developers check that all memory allocated since a previous call to __DbgMarkStart() has been freed.
(generated from Symbian Developer Library)
| UIMPORT_C void RAllocator::__DbgSetAllocFail | ( | TAllocFail | aType, |
| TInt | aRate | ||
| ) |
Simulates a heap allocation failure for this heap.
The failure occurs on subsequent calls to new or any of the functions which allocate memory from this heap.
The timing of the allocation failure depends on the type of allocation failure requested, i.e. on the value of aType.
The simulation of heap allocation failure is cancelled if aType is given the value RAllocator::ENone.
Notes:
| aType | An enumeration which indicates how to simulate heap allocation failure. |
| aRate | The rate of failure; when aType is RAllocator::EDeterministic, heap allocation fails every aRate attempts |
(generated from Symbian Developer Library)
| UIMPORT_C void RAllocator::__DbgSetBurstAllocFail | ( | TAllocFail | aType, |
| TUint | aRate, | ||
| TUint | aBurst | ||
| ) |
Simulates a burst of heap allocation failures for this heap.
The failure occurs for aBurst allocations attempt via subsequent calls to new or any of the functions which allocate memory from this heap.
The timing of the allocation failure depends on the type of allocation failure requested, i.e. on the value of aType.
The simulation of heap allocation failure is cancelled if aType is given the value RAllocator::ENone.
Notes:
| aType | An enumeration which indicates how to simulate heap allocation failure. |
| aRate | The rate of failure; when aType is RAllocator::EDeterministic, heap allocation fails every aRate attempts. |
| aBurst | The number of consecutive heap allocations that will fail each time the allocations should fail. |
(generated from Symbian Developer Library)
| UIMPORT_C TAny * RAllocator::Align | ( | TAny * | a | ) | const |
| UIMPORT_C TInt RAllocator::Align | ( | TInt | a | ) | const |
| IMPORT_C TAny * RAllocator::AllocL | ( | TInt | aSize | ) |
Allocates a cell of specified size from the heap, and leaves if there is insufficient memory in the heap.
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.
| aSize | The size of the cell to be allocated from the heap. |
Panic condition: USER 47 if the maximum unsigned value of aSize is greater than or equal to KMaxTInt/2. For example, calling Alloc(-1) raises this panic.
(generated from Symbian Developer Library)
| IMPORT_C TAny * RAllocator::AllocLC | ( | TInt | aSize | ) |
Allocates a cell of specified size from the heap, and, if successful, places a pointer to the cell onto the cleanup stack.
The function leaves if there is insufficient memory in the heap.
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.
| aSize | The size of the cell to be allocated from the heap. |
Panic condition: USER 47 if the maximum unsigned value of aSize is greater than or equal to KMaxTInt/2. For example, calling Alloc(-1) raises this panic.
(generated from Symbian Developer Library)
| IMPORT_C TAny * RAllocator::AllocZ | ( | TInt | aSize | ) |
Allocates a cell of specified size from the heap, and clears it to binary zeroes.
If there is insufficient memory available on the heap from which to allocate a cell of the required size, the function returns NULL.
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.
| aSize | The size of the cell to be allocated from the current thread's heap. |
Panic condition: USER 47 if the maximum unsigned value of aSize is greater than or equal to KMaxTInt/2. For example, calling Alloc(-1) raises this panic.
(generated from Symbian Developer Library)
| IMPORT_C TAny * RAllocator::AllocZL | ( | TInt | aSize | ) |
Allocates a cell of specified size from the heap, clears it to binary zeroes, and leaves if there is insufficient memory in the heap.
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.
| aSize | The size of the cell to be allocated from the heap. |
Panic condition: USER 47 if the maximum unsigned value of aSize is greater than or equal to KMaxTInt/2. For example, calling Alloc(-1) raises this panic.
(generated from Symbian Developer Library)
| UIMPORT_C TUint8 * RAllocator::Base | ( | ) | const |
| UIMPORT_C void RAllocator::Check | ( | ) | const |
Checks the validity of the heap.
The function walks through the list of allocated cells and the list of free cells checking that this heap is consistent and complete.
Panic condition: USER 47 if any corruption is found, specifically a bad allocated heap cell size.
Panic condition: USER 48 if any corruption is found, specifically a bad allocated heap cell address.
Panic condition: USER 49 if any corruption is found, specifically a bad free heap cell address.
(generated from Symbian Developer Library)
| IMPORT_C void RAllocator::Close | ( | ) |
Closes this shared heap.
Closing the heap decreases the heap's access count by one.
Panic condition: USER 57 if the access count has already reached zero.
(generated from Symbian Developer Library)
| IMPORT_C TInt RAllocator::Count | ( | ) | const |
Gets the total number of cells allocated on the heap.
(generated from Symbian Developer Library)
| IMPORT_C TInt RAllocator::Count | ( | TInt & | aFreeCount | ) | const |
Gets the the total number of cells allocated, and the number of free cells, on the heap.
| aFreeCount | On return, contains the number of free cells on the heap. |
(generated from Symbian Developer Library)
|
protectedvirtual |
|
protectedvirtual |
Implements MAllocator.
Reimplemented in RHeap.
| IMPORT_C void RAllocator::FreeZ | ( | TAny *& | aCell | ) |
Frees the specified cell, returns it to the heap, and resets the pointer to NULL.
| aCell | A reference to a pointer to a valid cell to be freed. If NULL this function call will be ignored. |
Panic condition: USER 42 if aCell is not NULL and does not point to a valid cell.
(generated from Symbian Developer Library)
| UIMPORT_C TInt RAllocator::MaxLength | ( | ) | const |
| IMPORT_C TInt RAllocator::Open | ( | ) |
Opens this heap for shared access.
Opening the heap increases the heap's access count by one.
(generated from Symbian Developer Library)
| IMPORT_C TAny * RAllocator::ReAllocL | ( | TAny * | aCell, |
| TInt | aSize, | ||
| TInt | aMode = 0 |
||
| ) |
Increases or decreases the size of an existing cell, and leaves if there is insufficient memory 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:
Note that in debug mode, the function leaves 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.
Note the following general points:
| aCell | A pointer to the cell to be reallocated. This may be NULL. |
| aSize | The new size of the cell. This may be bigger or smaller than the size of the original cell. |
| aMode | Flags controlling the reallocation. The only bit which has any effect on this function is that defined by the enumeration ENeverMove of the enum RAllocator::TReAllocMode. If this is set, then any successful reallocation guarantees not to have changed the start address of the cell. By default, this parameter is zero. |
Panic condition: USER 42, if aCell is not NULL, and does not point to a valid cell.
Panic condition: USER 47, if the maximum unsigned value of aSize is greater than or equal to KMaxTInt/2. For example, calling ReAlloc(someptr,-1) raises this panic.
(generated from Symbian Developer Library)
| UIMPORT_C TInt RAllocator::Size | ( | ) | const |