Example codes that explain how to use various cleanup functions.
Download
Click on the following link to download the example: ErrorOnFail.zip
Click: browse to view the example code.
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.
Class summary
Security issues
The example requires no specific capabilities in order to run - and does not demonstrate any security issues.
Download
Click on the following link to download the example: LeaveOnFail.zip
Click: browse to view the example code.
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.
Class summary
Security issues
The example requires no specific capabilities in order to run - and does not demonstrate any security issues.
Download
Click on the following link to download the example: ELeaveOnFail.zip
Click: browse to view the example code.
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.
Class summary
Security issues
The example requires no specific capabilities in order to run - and does not demonstrate any security issues.
Download
Click on the following link to download the example: TrapD.zip
click: browse to view the example code.
Description
The example shows the use of the TRAPD macro. It shows how a newly created object can be protected by the TRAPD macro.
Class summary
Security issues
The example requires no specific capabilities in order to run - and does not demonstrate any security issues.
Download
Click on the following link to download the example: PushLAndPop.zip
Click: browse to view the example code.
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.
Class summary
Security issues
The example requires no specific capabilities in order to run - and does not demonstrate any security issues.
Download
Click on the following link to download the example: PushLPopDest.zip
Click: browse to view the example code.
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.
Class summary
Security issues
The example requires no specific capabilities in order to run - and does not demonstrate any security issues.
Download
Click on the following link to download the example: NewL.zip
Click: browse to view the example code.
Description
The example shows use of the NewL() static function.
The example also uses the heap debugging macro __UHEAP_SETFAIL.
Class summary
Security issues
The example requires no specific capabilities in order to run - and does not demonstrate any security issues.
Download
Click on the following link to download the example: NewLC.zip
Click: browse to view the example code.
Description
The example shows use of the NewLC() static function.
The example also uses the heap debugging macro __UHEAP_SETFAIL.
Class summary
Security issues
The example requires no specific capabilities in order to run - and does not demonstrate any security issues.
Download
Click on the following link to download the example: SimpleOOM.zip
Click: browse to view the example code.
Description
This example shows cleanup handling for compound classes. The robustness of a simple class on Out Of Memory (OOM) is tested.
Class summary
Security issues
The example requires no specific capabilities in order to run - and does not demonstrate any security issues.
Download
Click on the following link to download the example: MemLeakOOM.zip
Click: browse to view the example code.
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.
Class summary
Security issues
The example requires no specific capabilities in order to run - and does not demonstrate any security issues.
Download
Click on the following link to download the example: TwoPhaseOOM.zip
click: browse to view the example code.
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.
Class summary
Security issues
The example requires no specific capabilities in order to run - and does not demonstrate any security issues.
Download
Download the example: TAnyRObjects1.zip
Download some additional files required by the example: CommonFramework.zip , HeaderFile.zip
View the source code: browse . View the additional files:CommonFramework , HeaderFile
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.
Class summary
Security issues
The example writes files to the executable's process private directory on the writable drive: \private\0FFFFF01\.
The second UID in the .mmp file is defined as 0x0FFFFF01 and this is used as the secure ID on which the name of the private directory is based.
Download
Download the example:TAnyRObjects2.zip
Download some additional files required by the example: CommonFramework.zip , HeaderFile.zip
View the source code: browse . View the additional files: CommonFramework , HeaderFile.
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.
Class summary
Security issues
The example writes files to the executable's process private directory: C:\private\0FFFFF02\.
The second UID in the .mmp file is defined as 0x0FFFFF02 and this is used as the secure ID on which the name of the private directory is based.
Download
Download the example: Utilities.zip
View the source code: browse. View the additional file: browse
Description
This example shows how the cleanup utilities (the templated functions CleanupDeletePushL(), CleanupClosePushL() and CleanupReleasePushL(), and CleanupArrayDeletePushL()) can be used.
Class summary
In addition to the templated functions:
the examples implicitly use the templated classes:
Examples of APIs
CleanupDelete<class T>
CleanupClose<class T>
CleanupRelease<class T>
CleanupArrayDelete<class T>
Security issues
The example requires no specific capabilities in order to run - and does not demonstrate any security issues.