Symbian Developer Library

SYMBIAN OS V6.1 EXAMPLE CODE

[Index] [Previous] [Next]



Cleanup support example code


ErrorOnFail—cleanup, TRAPD and leaving

Found in: epoc32ex\Base\MemMan\Cleanup\ErrorOnFail


Description

The example attempts to construct an object, and on failure it returns an appropriate error code.

This example shows use of the TRAPD macro, the cleanup stack and its functions PushL(), PopAndDestroy() and the process of leaving. It also uses the heap debugging macro __UHEAP_SETFAIL.


Usage

Run the example either under WINS or on the ARMI platform.


Classes used

[Top]


LeaveOnFail—cleanup, TRAPD and leaving

Found in: epoc32ex\Base\MemMan\Cleanup\LeaveOnFail


Description

As with the ErrorOnFail example, this example also attempts to construct an object, however on failure it simply leaves.

This example shows use of the TRAPD macro, the cleanup stack and its functions PushL(), PopAndDestroy() and the process of leaving. It also uses the heap debugging macro __UHEAP_SETFAIL.


Usage

Run the example either under WINS or on the ARMI platform.


Classes used

[Top]


ELeaveOnFail—cleanup, TRAPD and leaving

Found in: epoc32ex\Base\MemMan\Cleanup\ELeaveOnFail


Description

This example attempts to construct an object using the overloaded new operator new (ELeave). Specifying (ELeave) will cause a leave to occur if it was unable to allocate memory for the new object.

This example shows use of the TRAPD macro, the cleanup stack and its functions PushL(), PopAndDestroy() and the process of leaving. It also uses the heap debugging macro __UHEAP_SETFAIL.


Usage

Run the example either under WINS or on the ARMI platform.


Classes used

[Top]


TrapD—cleanup, TRAPD and leaving

Found in: epoc32ex\Base\MemMan\Cleanup\TrapD


Description

The example shows the use of the TRAPD macro. It shows how a newly created object can be protected by the TRAPD macro.


Usage

Run the example either under WINS or on the ARMI platform.


Classes used

[Top]


PushLAndPop—cleanup, TRAPD and leaving

Found in: epoc32ex\Base\MemMan\Cleanup\PushLAndPop


Description

The example shows the use of the cleanup stack and its functions PushL() and Pop().

The example also uses the heap debugging macro __UHEAP_SETFAIL.


Usage

Run the example either under WINS or on the ARMI platform.


Classes used

[Top]


PushLPopDest—cleanup, TRAPD and leaving

Found in: epoc32ex\Base\MemMan\Cleanup\PushLPopDest


Description

The example shows the use of the cleanup stack and its functions PushL() and PopAndDestroy().

The example also uses the heap debugging macro __UHEAP_SETFAIL.


Usage

Run the example either under WINS or on the ARMI platform.


Classes used

[Top]


NewL—cleanup, TRAPD and leaving

Found in: epoc32ex\Base\MemMan\Cleanup\NewL


Description

The example shows use of the NewL() static function.

The example also uses the heap debugging macro __UHEAP_SETFAIL.


Usage

Run the example either under WINS or on the ARMI platform.


Classes used

[Top]


NewLC—cleanup, TRAPD and leaving

Found in: epoc32ex\Base\MemMan\Cleanup\NewLC


Description

The example shows use of the NewLC() static function.

The example also uses the heap debugging macro __UHEAP_SETFAIL.


Usage

Run the example either under WINS or on the ARMI platform.


Classes used

[Top]


SimpleOOM—cleaning up compound classes

Found in: epoc32ex\Base\MemMan\Cleanup\SimpleOOM


Description

This example shows cleanup handling for compound classes. The robustness of a simple class on Out Of Memory (OOM) is tested.


Usage

Run the example either under WINS or on the ARMI platform.


Classes used

[Top]


MemLeakOOM—cleaning up compound classes

Found in: epoc32ex\Base\MemMan\Cleanup\MemLeakOOM


Description

This example shows cleanup handling for compound classes. The robustness of a compound class on Out Of Memory (OOM) is tested. It also shows how memory leaks can occur.


Usage

Run the example either under WINS or on the ARMI platform.


Classes used

[Top]


TwoPhaseOOM—cleaning up compound classes

Found in: epoc32ex\Base\MemMan\Cleanup\TwoPhaseOOM


Description

These examples show cleanup handling for compound classes. The robustness of a compound class on Out Of Memory (OOM) is tested. It also shows the use of the two phase construction technique.


Usage

Run the example either under WINS or on the ARMI platform.


Classes used

[Top]


TAnyRObjects1—cleaning up TAny* and ‘R’ type objects

Found in: epoc32ex\Base\MemMan\Cleanup\TAnyRObjects1


Description

The example shows how cleanup can be implemented for TAny* type objects and 'R' type (resource type) objects.

This example shows the use of TAny* cleanup type, for pushing a buffer to the cleanup stack. The buffer data is read from a file.

Class RFileWithCleanup is derived from class RFile, to show how to add cleanup support to a general R class.

This example adds cleanup support to the RFile.


Usage

Run the example either under WINS or on the ARMI platform.


Classes used

[Top]


TAnyRObjects2—cleaning up TAny* and ‘R’ type objects

Found in: epoc32ex\Base\MemMan\Cleanup\TAnyRObjects2


Description

The example shows how cleanup can be implemented for TAny* type objects and 'R' type (resource type) objects.

This example is similar to the TAnyRObjects1 example. However, it enhances the interface to include an OpenLC() which opens the file, and pushes it on to the cleanup stack in one function call.


Usage

Run the example either under WINS or on the ARMI platform.


Classes used

[Top]


Utilities—cleanup utilities

Found in: epoc32ex\Base\MemMan\Cleanup\Utilities


Description

This example shows how the cleanup utilities (the templated functions CleanupDeletePushL(), CleanupClosePushL() and CleanupReleasePushL()) can be used.


Usage

Run the example either under WINS or on the ARMI platform.


Classes used

In addition to the templated functions:

the examples implicitly use the templated classes: