Symbian3/PDK/Source/GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 13 Aug 2010 16:47:46 +0100
changeset 14 578be2adaf3e
parent 5 f345bda72bc4
permissions -rw-r--r--
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1" xml:lang="en"><title>Cleanup
Support Example Code</title><shortdesc>Example codes that explain how to use various cleanup functions.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<ul>
<li id="GUID-30B853A0-380E-5355-9D3C-F854BC77924D"><p> <xref href="GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1.dita#GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1/GUID-9CAE0C86-537A-500F-B361-D555DD39954B">ErrorOnFail: cleanup, TRAPD and leaving</xref> </p> </li>
<li id="GUID-21C594C4-57D2-56E1-88B9-2A9F37F2EFA6"><p> <xref href="GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1.dita#GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1/GUID-E80C29CC-0282-5350-8077-BB298B7590C0">LeaveOnFail: cleanup, TRAPD and leaving</xref> </p> </li>
<li id="GUID-D6653D68-E236-5C53-A07B-E72EAAC85F23"><p> <xref href="GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1.dita#GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1/GUID-279FBD9A-0E61-50ED-9618-BAB24AC3163C">ELeaveOnFail: cleanup, TRAPD and leaving</xref> </p> </li>
<li id="GUID-79C5A5BB-2A14-5148-9C17-7FE508BC7D17"><p> <xref href="GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1.dita#GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1/GUID-C7E94BD9-9B77-548C-A3C2-D5A396F20EF0">TrapD: cleanup, TRAPD and leaving</xref> </p> </li>
<li id="GUID-024B1B3E-19A5-5494-B382-482576A27E3E"><p> <xref href="GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1.dita#GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1/GUID-12F30817-5CE0-5B6E-A850-7179BE915539">PushLAndPop: cleanup, TRAPD and leaving</xref> </p> </li>
<li id="GUID-58BD5628-8D27-52D2-BFB3-9FBF5B6A97B9"><p> <xref href="GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1.dita#GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1/GUID-548F79C2-3394-5D86-8E70-B219E49288C7">PushLPopDest: cleanup, TRAPD and leaving</xref> </p> </li>
<li id="GUID-2F40CF99-E993-58D3-8C9E-517DB54BB237"><p> <xref href="GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1.dita#GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1/GUID-5975C52F-726D-5DB1-8CE4-7F52DC202B43">NewL: cleanup, TRAPD and leaving</xref> </p> </li>
<li id="GUID-9B4A5102-5C64-5E22-9D55-C6A53E48137A"><p> <xref href="GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1.dita#GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1/GUID-53F042FC-401F-5AD7-8F60-ECD15EB1069F">NewLC: cleanup, TRAPD and leaving</xref> </p> </li>
<li id="GUID-1DE76860-6FA4-5AA2-9C9B-8C7DCE01F97A"><p> <xref href="GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1.dita#GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1/GUID-4559C2AC-0DA8-5788-A33C-2E20EFEF6D58">SimpleOOM—cleaning up compound classes</xref> </p> </li>
<li id="GUID-94377071-3329-53C8-9EA2-ACFE90FB0413"><p> <xref href="GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1.dita#GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1/GUID-2E3E6224-BE1C-5DA1-BEA0-D28CD7DA40E8">MemLeakOOM: cleaning up compound classes</xref> </p> </li>
<li id="GUID-D099EA48-EC8D-5081-8A2F-E12FDB1B73F4"><p> <xref href="GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1.dita#GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1/GUID-068C17E6-0E3C-571B-92D1-421EEF42E6A0">TwoPhaseOOM: cleaning up compound classes</xref> </p> </li>
<li id="GUID-2D4E0AA0-3768-5E0D-B4FA-0E376BDB71DE"><p> <xref href="GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1.dita#GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1/GUID-D0A1DF34-2499-5F7E-80D1-0BFF74882EA6">TAnyRObjects1: cleaning up TAny* and "R" type objects</xref> </p> </li>
<li id="GUID-1EBC2006-351E-58EE-9611-98C260FD1A2C"><p> <xref href="GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1.dita#GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1/GUID-C42BF40F-94C4-5845-B449-164AD4578691">TAnyRObjects2: cleaning up TAny* and "R" type objects</xref> </p> </li>
<li id="GUID-EFAF518A-F1A7-5633-8CCA-2B3152F96919"><p> <xref href="GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1.dita#GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1/GUID-C4F81443-E41D-52C6-9305-A1B7E45A1DC5">Utilities: cleanup utilities</xref>. </p> </li>
</ul>
<section id="GUID-9CAE0C86-537A-500F-B361-D555DD39954B"><title>ErrorOnFail:
cleanup, TRAPD and leaving</title> <p><b>Download</b> </p> <p>Click on the
following link to download the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-2d7621ab-71a7-4a6f-bcd2-5c2e05888d00.zip" scope="external">ErrorOnFail.zip</xref></p><p>Click: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-2d7621ab-71a7-4a6f-bcd2-5c2e05888d00.html" scope="peer">browse </xref>to view the example code.</p> <p><b>Description</b> </p> <p>The
example attempts to construct an object, and on failure it returns an appropriate
error code. </p> <p>This example shows use of the <codeph>TRAPD</codeph> macro,
the cleanup stack and its functions <codeph>PushL()</codeph>, <codeph>PopAndDestroy()</codeph> and
the process of leaving. It also uses the heap debugging macro <codeph>__UHEAP_SETFAIL</codeph>. </p><p><b>Class
summary</b></p><ul>
<li><p><xref href="GUID-0DD554D7-B9B1-3FD3-898F-4D855144FCEA.dita"><apiname>CleanupStack</apiname></xref></p></li>
</ul> <p><b>Security issues</b> </p> <p>The example requires no specific capabilities
in order to run - and does not demonstrate any security issues. </p> </section>
<section id="GUID-E80C29CC-0282-5350-8077-BB298B7590C0"><title>LeaveOnFail:
cleanup, TRAPD and leaving</title> <p><b>Download</b> </p> <p>Click on the
following link to download the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-1e56dfe1-13ea-4e14-82b6-e7da3a8453f5.zip" scope="external">LeaveOnFail.zip</xref></p><p>Click: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-1e56dfe1-13ea-4e14-82b6-e7da3a8453f5.html" scope="peer">browse </xref>to view the example code.</p> <p><b>Description</b> </p> <p>As
with the <xref href="GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1.dita#GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1/GUID-9CAE0C86-537A-500F-B361-D555DD39954B">ErrorOnFail</xref> example,
this example also attempts to construct an object, however on failure it simply
leaves. </p> <p>This example shows use of the <codeph>TRAPD</codeph> macro,
the cleanup stack and its functions <codeph>PushL()</codeph>, <codeph>PopAndDestroy()</codeph> and
the process of leaving. It also uses the heap debugging macro <codeph>__UHEAP_SETFAIL</codeph>. </p><p><b>Class
summary</b></p><ul>
<li><p><xref href="GUID-0DD554D7-B9B1-3FD3-898F-4D855144FCEA.dita"><apiname>CleanupStack</apiname></xref></p></li>
</ul> <p><b>Security issues</b> </p> <p>The example requires no specific capabilities
in order to run - and does not demonstrate any security issues. </p> </section>
<section id="GUID-279FBD9A-0E61-50ED-9618-BAB24AC3163C"><title>ELeaveOnFail:
cleanup, TRAPD and leaving</title> <p><b>Download</b> </p> <p>Click on the
following link to download the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-16210a7c-3129-4176-a062-2a08b9947caf.zip" scope="external">ELeaveOnFail.zip</xref></p><p>Click: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-16210a7c-3129-4176-a062-2a08b9947caf.html" scope="peer">browse </xref>to view the example code.</p> <p><b>Description</b> </p> <p>This
example attempts to construct an object using the overloaded <codeph>new</codeph> operator <codeph>new
(ELeave)</codeph>. Specifying <codeph>(ELeave)</codeph> will cause a leave
to occur if it was unable to allocate memory for the new object. </p> <p>This
example shows use of the <codeph>TRAPD</codeph> macro, the cleanup stack and
its functions <codeph>PushL()</codeph>, <codeph>PopAndDestroy()</codeph> and
the process of leaving. It also uses the heap debugging macro <codeph>__UHEAP_SETFAIL</codeph>. </p><p><b>Class
summary</b></p><ul>
<li><p><xref href="GUID-0DD554D7-B9B1-3FD3-898F-4D855144FCEA.dita"><apiname>CleanupStack</apiname></xref></p></li>
</ul> <p><b>Security issues</b> </p> <p>The example requires no specific capabilities
in order to run - and does not demonstrate any security issues. </p> </section>
<section id="GUID-C7E94BD9-9B77-548C-A3C2-D5A396F20EF0"><title>TrapD: cleanup,
TRAPD and leaving</title> <p><b>Download</b> </p> <p>Click on the following
link to download the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-de1a3a49-8773-46c3-8469-be9777f09870.zip" scope="external">TrapD.zip</xref></p><p>click: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-de1a3a49-8773-46c3-8469-be9777f09870.html" scope="peer">browse </xref>to view the example code.</p> <p><b>Description</b> </p> <p>The
example shows the use of the <codeph>TRAPD</codeph> macro. It shows how a
newly created object can be protected by the <codeph>TRAPD</codeph> macro. </p><p><b>Class
summary</b></p><ul>
<li><p><xref href="GUID-0DD554D7-B9B1-3FD3-898F-4D855144FCEA.dita"><apiname>CleanupStack</apiname></xref></p></li>
</ul> <p><b>Security issues</b> </p> <p>The example requires no specific capabilities
in order to run - and does not demonstrate any security issues. </p> </section>
<section id="GUID-12F30817-5CE0-5B6E-A850-7179BE915539"><title>PushLAndPop:
cleanup, TRAPD and leaving</title> <p><b>Download</b> </p> <p>Click on the
following link to download the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-50fd89b6-237a-4f9d-bed1-21678cc5ab5b.zip" scope="external">PushLAndPop.zip</xref></p><p>Click: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-50fd89b6-237a-4f9d-bed1-21678cc5ab5b.html" scope="peer">browse </xref>to view the example code.</p> <p><b>Description</b> </p> <p>The
example shows the use of the cleanup stack and its functions <codeph>PushL()</codeph> and <codeph>Pop()</codeph>. </p> <p>The
example also uses the heap debugging macro <codeph>__UHEAP_SETFAIL.</codeph>  </p><p><b>Class
summary</b></p><ul>
<li><p><xref href="GUID-0DD554D7-B9B1-3FD3-898F-4D855144FCEA.dita"><apiname>CleanupStack</apiname></xref></p></li>
</ul> <p><b>Security issues</b> </p> <p>The example requires no specific capabilities
in order to run - and does not demonstrate any security issues. </p> </section>
<section id="GUID-548F79C2-3394-5D86-8E70-B219E49288C7"><title>PushLPopDest:
cleanup, TRAPD and leaving</title> <p><b>Download</b> </p> <p>Click on the
following link to download the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-03d19c0a-a64a-4e18-ba8c-7d563e6df331.zip" scope="external">PushLPopDest.zip</xref></p><p>Click: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-03d19c0a-a64a-4e18-ba8c-7d563e6df331.html" scope="peer">browse </xref>to view the example code.</p> <p><b>Description</b> </p> <p>The
example shows the use of the cleanup stack and its functions <codeph>PushL()</codeph> and <codeph>PopAndDestroy()</codeph>. </p> <p>The
example also uses the heap debugging macro <codeph>__UHEAP_SETFAIL</codeph>. </p><p><b>Class
summary</b></p><ul>
<li><p><xref href="GUID-0DD554D7-B9B1-3FD3-898F-4D855144FCEA.dita"><apiname>CleanupStack</apiname></xref></p></li>
</ul> <p><b>Security issues</b> </p> <p>The example requires no specific capabilities
in order to run - and does not demonstrate any security issues. </p> </section>
<section id="GUID-5975C52F-726D-5DB1-8CE4-7F52DC202B43"><title>NewL: cleanup,
TRAPD and leaving</title> <p><b>Download</b> </p> <p>Click on the following
link to download the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-ed6e0d71-cada-4370-b55e-e7239e75b707.zip" scope="external">NewL.zip</xref></p><p>Click: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-ed6e0d71-cada-4370-b55e-e7239e75b707.html" scope="peer">browse </xref>to view the example code.</p> <p><b>Description</b> </p> <p>The
example shows use of the <codeph>NewL()</codeph> static function. </p> <p>The
example also uses the heap debugging macro <codeph>__UHEAP_SETFAIL</codeph>. </p><p><b>Class
summary</b></p><ul>
<li><p><xref href="GUID-0DD554D7-B9B1-3FD3-898F-4D855144FCEA.dita"><apiname>CleanupStack</apiname></xref></p></li>
</ul> <p><b>Security issues</b> </p> <p>The example requires no specific capabilities
in order to run - and does not demonstrate any security issues. </p> </section>
<section id="GUID-53F042FC-401F-5AD7-8F60-ECD15EB1069F"><title>NewLC: cleanup,
TRAPD and leaving</title> <p><b>Download</b> </p> <p>Click on the following
link to download the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-a3ff31ac-53a8-4719-aa9c-f45874214852.zip" scope="external">NewLC.zip</xref></p><p>Click: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-a3ff31ac-53a8-4719-aa9c-f45874214852.html" scope="peer">browse </xref>to view the example code.</p> <p><b>Description</b> </p> <p>The
example shows use of the <codeph>NewLC()</codeph> static function. </p> <p>The
example also uses the heap debugging macro <codeph>__UHEAP_SETFAIL</codeph>. </p><p><b>Class
summary</b></p><ul>
<li><p><xref href="GUID-0DD554D7-B9B1-3FD3-898F-4D855144FCEA.dita"><apiname>CleanupStack</apiname></xref></p></li>
</ul> <p><b>Security issues</b> </p> <p>The example requires no specific capabilities
in order to run - and does not demonstrate any security issues. </p> </section>
<section id="GUID-4559C2AC-0DA8-5788-A33C-2E20EFEF6D58"><title>SimpleOOM—cleaning
up compound classes</title> <p><b>Download</b> </p> <p>Click on the following
link to download the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-71eeb97f-c662-46cb-b5b8-aefd8aa4439e.zip" scope="external">SimpleOOM.zip</xref></p><p>Click: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-71eeb97f-c662-46cb-b5b8-aefd8aa4439e.html" scope="peer">browse </xref>to view the example code.</p> <p><b>Description</b> </p> <p>This
example shows cleanup handling for compound classes. The robustness of a simple
class on Out Of Memory (OOM) is tested. </p><p><b>Class summary</b></p><ul>
<li><p><xref href="GUID-0DD554D7-B9B1-3FD3-898F-4D855144FCEA.dita"><apiname>CleanupStack</apiname></xref></p></li>
</ul> <p><b>Security issues</b> </p> <p>The example requires no specific capabilities
in order to run - and does not demonstrate any security issues. </p> </section>
<section id="GUID-2E3E6224-BE1C-5DA1-BEA0-D28CD7DA40E8"><title>MemLeakOOM:
cleaning up compound classes</title> <p><b>Download</b> </p> <p>Click on the
following link to download the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-873c620d-c7f2-48f5-9472-2ad61a5c7594.zip" scope="external">MemLeakOOM.zip</xref></p><p>Click: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-873c620d-c7f2-48f5-9472-2ad61a5c7594.html" scope="peer">browse </xref>to view the example code.</p> <p><b>Description</b> </p> <p>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. </p><p><b>Class summary</b></p><ul>
<li><p><xref href="GUID-0DD554D7-B9B1-3FD3-898F-4D855144FCEA.dita"><apiname>CleanupStack</apiname></xref></p></li>
</ul> <p><b>Security issues</b> </p> <p>The example requires no specific capabilities
in order to run - and does not demonstrate any security issues. </p> </section>
<section id="GUID-068C17E6-0E3C-571B-92D1-421EEF42E6A0"><title>TwoPhaseOOM:
cleaning up compound classes</title> <p><b>Download</b> </p> <p>Click on the
following link to download the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-77965fa6-4624-42dc-8104-dd973dff7132.zip" scope="external">TwoPhaseOOM.zip</xref></p><p>click: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-77965fa6-4624-42dc-8104-dd973dff7132.html" scope="peer">browse </xref>to view the example code.</p> <p><b>Description</b> </p> <p>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. </p><p><b>Class summary</b></p><ul>
<li><p><xref href="GUID-0DD554D7-B9B1-3FD3-898F-4D855144FCEA.dita"><apiname>CleanupStack</apiname></xref></p></li>
</ul> <p><b>Security issues</b> </p> <p>The example requires no specific capabilities
in order to run - and does not demonstrate any security issues. </p> </section>
<section id="GUID-D0A1DF34-2499-5F7E-80D1-0BFF74882EA6"><title>TAnyRObjects1:
cleaning up TAny* and ‘R’ type objects</title> <p><b>Download</b> </p> <p>Download
the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-4aeb7aba-6ce4-4ec4-bc80-04722c55fd73.zip" scope="external">TAnyRObjects1.zip</xref> </p><p>Download some additional
files required by the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-4184e6d4-8dbe-4267-b1a3-8737c8bf64ce.zip" scope="external">CommonFramework.zip</xref> , <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-306f220f-1980-4b1c-914e-d643a49f9d97.zip" scope="external">HeaderFile.zip</xref></p><p>View the source code: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-4aeb7aba-6ce4-4ec4-bc80-04722c55fd73.html" scope="peer">browse</xref> . View the additional files:<xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-4184e6d4-8dbe-4267-b1a3-8737c8bf64ce.html" scope="peer">CommonFramework</xref> , <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-306f220f-1980-4b1c-914e-d643a49f9d97.html" scope="peer">HeaderFile</xref></p> <p><b>Description</b> </p> <p>The example
shows how cleanup can be implemented for <codeph>TAny*</codeph> type objects
and 'R' type (resource type) objects. </p> <p>This example shows the use of <codeph>TAny*</codeph> cleanup
type, for pushing a buffer to the cleanup stack. The buffer data is read from
a file. </p> <p>Class <filepath>RFileWithCleanup</filepath> is derived from
class <filepath>RFile</filepath>, to show how to add cleanup support to a
general <filepath>R</filepath> class. </p> <p>This example adds cleanup support
to the <filepath>RFile</filepath>. </p><p><b>Class summary</b></p><ul>
<li><p><xref href="GUID-0DD554D7-B9B1-3FD3-898F-4D855144FCEA.dita"><apiname>CleanupStack</apiname></xref></p></li>
<li><p><xref href="GUID-BE0804F6-4375-3C8A-8C83-968F510466E0.dita"><apiname>RFile</apiname></xref></p></li>
</ul> <p><b>Security issues</b> </p> <p>The example writes files to the executable's
process private directory on the writable drive: <filepath>\private\0FFFFF01\</filepath>. </p> <p>The
second UID in the <filepath>.mmp</filepath> file is defined as <codeph>0x0FFFFF01</codeph> and
this is used as the secure ID on which the name of the private directory is
based. </p> </section>
<section id="GUID-C42BF40F-94C4-5845-B449-164AD4578691"><title>TAnyRObjects2:
cleaning up TAny* and ‘R’ type objects</title> <p><b>Download</b> </p> <p>Download
the example:<xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-2a8a3745-6fc5-4b7e-bceb-c975b9126318.zip" scope="external">TAnyRObjects2.zip</xref> </p><p>Download some additional
files required by the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-4184e6d4-8dbe-4267-b1a3-8737c8bf64ce.zip" scope="external">CommonFramework.zip</xref> , <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-306f220f-1980-4b1c-914e-d643a49f9d97.zip" scope="external">HeaderFile.zip</xref></p><p>View the source code: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-2a8a3745-6fc5-4b7e-bceb-c975b9126318.html" scope="peer">browse</xref> . View the additional files: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-4184e6d4-8dbe-4267-b1a3-8737c8bf64ce.html" scope="peer">CommonFramework</xref> , <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-306f220f-1980-4b1c-914e-d643a49f9d97.html" scope="peer">HeaderFile</xref>.</p> <p><b>Description</b> </p> <p>The example
shows how cleanup can be implemented for <codeph>TAny</codeph> * type objects
and 'R' type (resource type) objects. </p> <p>This example is similar to the <xref href="GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1.dita#GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1/GUID-D0A1DF34-2499-5F7E-80D1-0BFF74882EA6">TAnyRObjects1</xref> example.
However, it enhances the interface to include an <codeph>OpenLC()</codeph> which
opens the file, and pushes it on to the cleanup stack in one function call. </p><p><b>Class
summary</b></p><ul>
<li><p><xref href="GUID-0DD554D7-B9B1-3FD3-898F-4D855144FCEA.dita"><apiname>CleanupStack</apiname></xref></p></li>
<li><p><xref href="GUID-BE0804F6-4375-3C8A-8C83-968F510466E0.dita"><apiname>RFile</apiname></xref></p></li>
</ul> <p><b>Security issues</b> </p> <p>The example writes files to the executable's
process private directory: <filepath>C:\private\0FFFFF02\</filepath>. </p> <p>The
second UID in the <filepath>.mmp</filepath> file is defined as <codeph>0x0FFFFF02</codeph> and
this is used as the secure ID on which the name of the private directory is
based. </p> </section>
<section id="GUID-C4F81443-E41D-52C6-9305-A1B7E45A1DC5"><title>Utilities:
cleanup utilities</title> <p><b>Download</b> </p> <p>Download the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-cd5a50ad-f191-4f0f-a266-a76d1d633092.zip" scope="external">Utilities.zip</xref></p><p><xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-4184e6d4-8dbe-4267-b1a3-8737c8bf64ce.zip" scope="external">CommonFramework.zip</xref>.</p><p>View the source code: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-cd5a50ad-f191-4f0f-a266-a76d1d633092.html" scope="peer">browse</xref>.  View the additional file: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-4184e6d4-8dbe-4267-b1a3-8737c8bf64ce.html" scope="peer">browse</xref></p> <p><b>Description</b> </p> <p>This example
shows how the cleanup utilities (the templated functions <codeph>CleanupDeletePushL()</codeph>, <codeph>CleanupClosePushL()</codeph> and <codeph>CleanupReleasePushL()</codeph>, and <codeph>CleanupArrayDeletePushL()</codeph>) can be used. </p><p><b>Class
summary</b></p><p> In addition to the templated functions:</p><ul>
<li><p><xref href="GUID-2ECB3F11-6299-351C-B9D0-488C06559A6D.dita"><apiname>CleanupDeletePushL()</apiname></xref></p></li>
<li><p> <xref href="GUID-16B0008A-0F85-3C1E-89E1-E7431E2C93B9.dita"><apiname>CleanupClosePushL() </apiname></xref></p></li>
<li><p><xref href="GUID-B432961B-2613-3DAE-9260-67F53CC6B751.dita"><apiname>CleanupReleasePushL() </apiname></xref></p></li>
<li><p> <xref href="GUID-145951D8-0A0F-31D2-B272-F46C037449E0.dita"><apiname>CleanupArrayDeletePushL()</apiname></xref></p></li>
</ul><p>the examples implicitly use the templated classes:</p><p>Examples
of APIs</p><ul>
<li><p>CleanupDelete&lt;class T&gt;</p></li>
<li><p>CleanupClose&lt;class T&gt;</p></li>
<li><p>CleanupRelease&lt;class T&gt;</p></li>
<li><p>CleanupArrayDelete&lt;class T&gt;</p></li>
</ul> <p><b>Security issues</b> </p> <p>The example requires no specific capabilities
in order to run - and does not demonstrate any security issues. </p> </section>
</conbody></concept>