Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Location: e32std.h
Link against: euser.lib

Class UserHeap

UserHeap

Support

Supported from 5.0

Description

A set of static functions for constructing fixed length heaps and local or global heaps.

Defined in UserHeap:
ChunkHeap(), FixedHeap()

See also:


Member functions


FixedHeap()

static RHeap* FixedHeap(TAny* aBase,TInt aMaxLength);

Description

Creates a fixed length heap at a specified location. On successful return from this function, aMaxLength bytes are committed by the chunk.

The heap cannot be extended.

Note that the heap is of type EFixedAddress.

Parameters

TAny* aBase

A pointer to the location where the heap is to be constructed.

TInt aMaxLength

The length of the heap. The supplied value must not be negative, otherwise the function raises a USER 56 panic. If the supplied value is less than KMinHeapSize, it is discarded and the value KMinHeapSize used instead.KMinHeapSize is defined in e32std.h.

Return value

RHeap*

A pointer to the new heap or NULL if the heap could not be created.


ChunkHeap()

static RHeap* ChunkHeap(const TDesC* aName,TInt aMinLength,TInt aMaxLength,TInt aGrowBy=KMinHeapGrowBy);

Description

Creates a heap in a local or global chunk. The chunk hosting the heap can be local or global.

A local chunk is one which is private to the process creating it and is not intended for access by other user processes. A global chunk is one which is visible to all processes.

The hosting chunk is local, if the pointer aName is NULL, otherwise the hosting chunk is global and the descriptor *aName is assumed to contain the name to be assigned to it.

Ownership of the host chunk is vested in the current process.

A minimum and a maximum size for the heap can be specified. On successful return from this function, the size of the heap is at least aMinLength. If subsequent requests for allocation of memory from the heap cannot be satisfied by compressing the heap, the size of the heap is extended in increments of aGrowBy until the request can be satisfied. Attempts to extend the heap causes the size of the host chunk to be adjusted.

Note:

Parameters

const TDesC* aName

If NULL, the function constructs a local chunk to host the heap If not NULL, a pointer to a descriptor containing the name to be assigned to the global chunk hosting the heap.

TInt aMinLength

The minimum length of the heap. The value must not be negative, otherwise the function raises a USER 55 panic. The value must be less than or equal to the supplied value of aMaxLength, otherwise the function raises a USER 41 panic.

TInt aMaxLength

The maximum length to which the heap can grow. The value must not be negative, otherwise the function raises a USER 56 panic. The value must be greater than or equal to the supplied value of aMaxLength, otherwise the function raises a USER 41 panic. If the supplied value is less than KMinHeapSize, then it is discarded and the value KMinHeapSize used instead.KMinHeapSize is defined in e32std.h.

TInt aGrowBy

The increments to the size of the host chunk. If a value is not explicitly specified, the value KMinHeapGrowBy is taken by default

Return value

RHeap*

A pointer to the new heap or NULL if the heap could not be created.