|
1 <?xml version="1.0" encoding="utf-8"?> |
|
2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. --> |
|
3 <!-- This component and the accompanying materials are made available under the terms of the License |
|
4 "Eclipse Public License v1.0" which accompanies this distribution, |
|
5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". --> |
|
6 <!-- Initial Contributors: |
|
7 Nokia Corporation - initial contribution. |
|
8 Contributors: |
|
9 --> |
|
10 <!DOCTYPE concept |
|
11 PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"> |
|
12 <concept id="GUID-16DD2138-617F-57EA-9A35-70155AA7F7D1" xml:lang="en"><title>Cleanup |
|
13 Support Example Code</title><shortdesc>Example codes that explain how to use various cleanup functions.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody> |
|
14 <ul> |
|
15 <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> |
|
16 <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> |
|
17 <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> |
|
18 <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> |
|
19 <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> |
|
20 <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> |
|
21 <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> |
|
22 <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> |
|
23 <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> |
|
24 <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> |
|
25 <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> |
|
26 <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> |
|
27 <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> |
|
28 <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> |
|
29 </ul> |
|
30 <section id="GUID-9CAE0C86-537A-500F-B361-D555DD39954B"><title>ErrorOnFail: |
|
31 cleanup, TRAPD and leaving</title> <p><b>Download</b> </p> <p>Click on the |
|
32 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 |
|
33 example attempts to construct an object, and on failure it returns an appropriate |
|
34 error code. </p> <p>This example shows use of the <codeph>TRAPD</codeph> macro, |
|
35 the cleanup stack and its functions <codeph>PushL()</codeph>, <codeph>PopAndDestroy()</codeph> and |
|
36 the process of leaving. It also uses the heap debugging macro <codeph>__UHEAP_SETFAIL</codeph>. </p><p><b>Class |
|
37 summary</b></p><ul> |
|
38 <li><p><xref href="GUID-0DD554D7-B9B1-3FD3-898F-4D855144FCEA.dita"><apiname>CleanupStack</apiname></xref></p></li> |
|
39 </ul> <p><b>Security issues</b> </p> <p>The example requires no specific capabilities |
|
40 in order to run - and does not demonstrate any security issues. </p> </section> |
|
41 <section id="GUID-E80C29CC-0282-5350-8077-BB298B7590C0"><title>LeaveOnFail: |
|
42 cleanup, TRAPD and leaving</title> <p><b>Download</b> </p> <p>Click on the |
|
43 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 |
|
44 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, |
|
45 this example also attempts to construct an object, however on failure it simply |
|
46 leaves. </p> <p>This example shows use of the <codeph>TRAPD</codeph> macro, |
|
47 the cleanup stack and its functions <codeph>PushL()</codeph>, <codeph>PopAndDestroy()</codeph> and |
|
48 the process of leaving. It also uses the heap debugging macro <codeph>__UHEAP_SETFAIL</codeph>. </p><p><b>Class |
|
49 summary</b></p><ul> |
|
50 <li><p><xref href="GUID-0DD554D7-B9B1-3FD3-898F-4D855144FCEA.dita"><apiname>CleanupStack</apiname></xref></p></li> |
|
51 </ul> <p><b>Security issues</b> </p> <p>The example requires no specific capabilities |
|
52 in order to run - and does not demonstrate any security issues. </p> </section> |
|
53 <section id="GUID-279FBD9A-0E61-50ED-9618-BAB24AC3163C"><title>ELeaveOnFail: |
|
54 cleanup, TRAPD and leaving</title> <p><b>Download</b> </p> <p>Click on the |
|
55 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 |
|
56 example attempts to construct an object using the overloaded <codeph>new</codeph> operator <codeph>new |
|
57 (ELeave)</codeph>. Specifying <codeph>(ELeave)</codeph> will cause a leave |
|
58 to occur if it was unable to allocate memory for the new object. </p> <p>This |
|
59 example shows use of the <codeph>TRAPD</codeph> macro, the cleanup stack and |
|
60 its functions <codeph>PushL()</codeph>, <codeph>PopAndDestroy()</codeph> and |
|
61 the process of leaving. It also uses the heap debugging macro <codeph>__UHEAP_SETFAIL</codeph>. </p><p><b>Class |
|
62 summary</b></p><ul> |
|
63 <li><p><xref href="GUID-0DD554D7-B9B1-3FD3-898F-4D855144FCEA.dita"><apiname>CleanupStack</apiname></xref></p></li> |
|
64 </ul> <p><b>Security issues</b> </p> <p>The example requires no specific capabilities |
|
65 in order to run - and does not demonstrate any security issues. </p> </section> |
|
66 <section id="GUID-C7E94BD9-9B77-548C-A3C2-D5A396F20EF0"><title>TrapD: cleanup, |
|
67 TRAPD and leaving</title> <p><b>Download</b> </p> <p>Click on the following |
|
68 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 |
|
69 example shows the use of the <codeph>TRAPD</codeph> macro. It shows how a |
|
70 newly created object can be protected by the <codeph>TRAPD</codeph> macro. </p><p><b>Class |
|
71 summary</b></p><ul> |
|
72 <li><p><xref href="GUID-0DD554D7-B9B1-3FD3-898F-4D855144FCEA.dita"><apiname>CleanupStack</apiname></xref></p></li> |
|
73 </ul> <p><b>Security issues</b> </p> <p>The example requires no specific capabilities |
|
74 in order to run - and does not demonstrate any security issues. </p> </section> |
|
75 <section id="GUID-12F30817-5CE0-5B6E-A850-7179BE915539"><title>PushLAndPop: |
|
76 cleanup, TRAPD and leaving</title> <p><b>Download</b> </p> <p>Click on the |
|
77 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 |
|
78 example shows the use of the cleanup stack and its functions <codeph>PushL()</codeph> and <codeph>Pop()</codeph>. </p> <p>The |
|
79 example also uses the heap debugging macro <codeph>__UHEAP_SETFAIL.</codeph> </p><p><b>Class |
|
80 summary</b></p><ul> |
|
81 <li><p><xref href="GUID-0DD554D7-B9B1-3FD3-898F-4D855144FCEA.dita"><apiname>CleanupStack</apiname></xref></p></li> |
|
82 </ul> <p><b>Security issues</b> </p> <p>The example requires no specific capabilities |
|
83 in order to run - and does not demonstrate any security issues. </p> </section> |
|
84 <section id="GUID-548F79C2-3394-5D86-8E70-B219E49288C7"><title>PushLPopDest: |
|
85 cleanup, TRAPD and leaving</title> <p><b>Download</b> </p> <p>Click on the |
|
86 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 |
|
87 example shows the use of the cleanup stack and its functions <codeph>PushL()</codeph> and <codeph>PopAndDestroy()</codeph>. </p> <p>The |
|
88 example also uses the heap debugging macro <codeph>__UHEAP_SETFAIL</codeph>. </p><p><b>Class |
|
89 summary</b></p><ul> |
|
90 <li><p><xref href="GUID-0DD554D7-B9B1-3FD3-898F-4D855144FCEA.dita"><apiname>CleanupStack</apiname></xref></p></li> |
|
91 </ul> <p><b>Security issues</b> </p> <p>The example requires no specific capabilities |
|
92 in order to run - and does not demonstrate any security issues. </p> </section> |
|
93 <section id="GUID-5975C52F-726D-5DB1-8CE4-7F52DC202B43"><title>NewL: cleanup, |
|
94 TRAPD and leaving</title> <p><b>Download</b> </p> <p>Click on the following |
|
95 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 |
|
96 example shows use of the <codeph>NewL()</codeph> static function. </p> <p>The |
|
97 example also uses the heap debugging macro <codeph>__UHEAP_SETFAIL</codeph>. </p><p><b>Class |
|
98 summary</b></p><ul> |
|
99 <li><p><xref href="GUID-0DD554D7-B9B1-3FD3-898F-4D855144FCEA.dita"><apiname>CleanupStack</apiname></xref></p></li> |
|
100 </ul> <p><b>Security issues</b> </p> <p>The example requires no specific capabilities |
|
101 in order to run - and does not demonstrate any security issues. </p> </section> |
|
102 <section id="GUID-53F042FC-401F-5AD7-8F60-ECD15EB1069F"><title>NewLC: cleanup, |
|
103 TRAPD and leaving</title> <p><b>Download</b> </p> <p>Click on the following |
|
104 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 |
|
105 example shows use of the <codeph>NewLC()</codeph> static function. </p> <p>The |
|
106 example also uses the heap debugging macro <codeph>__UHEAP_SETFAIL</codeph>. </p><p><b>Class |
|
107 summary</b></p><ul> |
|
108 <li><p><xref href="GUID-0DD554D7-B9B1-3FD3-898F-4D855144FCEA.dita"><apiname>CleanupStack</apiname></xref></p></li> |
|
109 </ul> <p><b>Security issues</b> </p> <p>The example requires no specific capabilities |
|
110 in order to run - and does not demonstrate any security issues. </p> </section> |
|
111 <section id="GUID-4559C2AC-0DA8-5788-A33C-2E20EFEF6D58"><title>SimpleOOM—cleaning |
|
112 up compound classes</title> <p><b>Download</b> </p> <p>Click on the following |
|
113 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 |
|
114 example shows cleanup handling for compound classes. The robustness of a simple |
|
115 class on Out Of Memory (OOM) is tested. </p><p><b>Class summary</b></p><ul> |
|
116 <li><p><xref href="GUID-0DD554D7-B9B1-3FD3-898F-4D855144FCEA.dita"><apiname>CleanupStack</apiname></xref></p></li> |
|
117 </ul> <p><b>Security issues</b> </p> <p>The example requires no specific capabilities |
|
118 in order to run - and does not demonstrate any security issues. </p> </section> |
|
119 <section id="GUID-2E3E6224-BE1C-5DA1-BEA0-D28CD7DA40E8"><title>MemLeakOOM: |
|
120 cleaning up compound classes</title> <p><b>Download</b> </p> <p>Click on the |
|
121 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 |
|
122 example shows cleanup handling for compound classes. The robustness of a compound |
|
123 class on Out Of Memory (OOM) is tested. It also shows how memory leaks can |
|
124 occur. </p><p><b>Class summary</b></p><ul> |
|
125 <li><p><xref href="GUID-0DD554D7-B9B1-3FD3-898F-4D855144FCEA.dita"><apiname>CleanupStack</apiname></xref></p></li> |
|
126 </ul> <p><b>Security issues</b> </p> <p>The example requires no specific capabilities |
|
127 in order to run - and does not demonstrate any security issues. </p> </section> |
|
128 <section id="GUID-068C17E6-0E3C-571B-92D1-421EEF42E6A0"><title>TwoPhaseOOM: |
|
129 cleaning up compound classes</title> <p><b>Download</b> </p> <p>Click on the |
|
130 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 |
|
131 examples show cleanup handling for compound classes. The robustness of a compound |
|
132 class on Out Of Memory (OOM) is tested. It also shows the use of the two phase |
|
133 construction technique. </p><p><b>Class summary</b></p><ul> |
|
134 <li><p><xref href="GUID-0DD554D7-B9B1-3FD3-898F-4D855144FCEA.dita"><apiname>CleanupStack</apiname></xref></p></li> |
|
135 </ul> <p><b>Security issues</b> </p> <p>The example requires no specific capabilities |
|
136 in order to run - and does not demonstrate any security issues. </p> </section> |
|
137 <section id="GUID-D0A1DF34-2499-5F7E-80D1-0BFF74882EA6"><title>TAnyRObjects1: |
|
138 cleaning up TAny* and ‘R’ type objects</title> <p><b>Download</b> </p> <p>Download |
|
139 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 |
|
140 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 |
|
141 shows how cleanup can be implemented for <codeph>TAny*</codeph> type objects |
|
142 and 'R' type (resource type) objects. </p> <p>This example shows the use of <codeph>TAny*</codeph> cleanup |
|
143 type, for pushing a buffer to the cleanup stack. The buffer data is read from |
|
144 a file. </p> <p>Class <filepath>RFileWithCleanup</filepath> is derived from |
|
145 class <filepath>RFile</filepath>, to show how to add cleanup support to a |
|
146 general <filepath>R</filepath> class. </p> <p>This example adds cleanup support |
|
147 to the <filepath>RFile</filepath>. </p><p><b>Class summary</b></p><ul> |
|
148 <li><p><xref href="GUID-0DD554D7-B9B1-3FD3-898F-4D855144FCEA.dita"><apiname>CleanupStack</apiname></xref></p></li> |
|
149 <li><p><xref href="GUID-BE0804F6-4375-3C8A-8C83-968F510466E0.dita"><apiname>RFile</apiname></xref></p></li> |
|
150 </ul> <p><b>Security issues</b> </p> <p>The example writes files to the executable's |
|
151 process private directory on the writable drive: <filepath>\private\0FFFFF01\</filepath>. </p> <p>The |
|
152 second UID in the <filepath>.mmp</filepath> file is defined as <codeph>0x0FFFFF01</codeph> and |
|
153 this is used as the secure ID on which the name of the private directory is |
|
154 based. </p> </section> |
|
155 <section id="GUID-C42BF40F-94C4-5845-B449-164AD4578691"><title>TAnyRObjects2: |
|
156 cleaning up TAny* and ‘R’ type objects</title> <p><b>Download</b> </p> <p>Download |
|
157 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 |
|
158 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 |
|
159 shows how cleanup can be implemented for <codeph>TAny</codeph> * type objects |
|
160 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. |
|
161 However, it enhances the interface to include an <codeph>OpenLC()</codeph> which |
|
162 opens the file, and pushes it on to the cleanup stack in one function call. </p><p><b>Class |
|
163 summary</b></p><ul> |
|
164 <li><p><xref href="GUID-0DD554D7-B9B1-3FD3-898F-4D855144FCEA.dita"><apiname>CleanupStack</apiname></xref></p></li> |
|
165 <li><p><xref href="GUID-BE0804F6-4375-3C8A-8C83-968F510466E0.dita"><apiname>RFile</apiname></xref></p></li> |
|
166 </ul> <p><b>Security issues</b> </p> <p>The example writes files to the executable's |
|
167 process private directory: <filepath>C:\private\0FFFFF02\</filepath>. </p> <p>The |
|
168 second UID in the <filepath>.mmp</filepath> file is defined as <codeph>0x0FFFFF02</codeph> and |
|
169 this is used as the secure ID on which the name of the private directory is |
|
170 based. </p> </section> |
|
171 <section id="GUID-C4F81443-E41D-52C6-9305-A1B7E45A1DC5"><title>Utilities: |
|
172 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 |
|
173 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 |
|
174 summary</b></p><p> In addition to the templated functions:</p><ul> |
|
175 <li><p><xref href="GUID-2ECB3F11-6299-351C-B9D0-488C06559A6D.dita"><apiname>CleanupDeletePushL()</apiname></xref></p></li> |
|
176 <li><p> <xref href="GUID-16B0008A-0F85-3C1E-89E1-E7431E2C93B9.dita"><apiname>CleanupClosePushL() </apiname></xref></p></li> |
|
177 <li><p><xref href="GUID-B432961B-2613-3DAE-9260-67F53CC6B751.dita"><apiname>CleanupReleasePushL() </apiname></xref></p></li> |
|
178 <li><p> <xref href="GUID-145951D8-0A0F-31D2-B272-F46C037449E0.dita"><apiname>CleanupArrayDeletePushL()</apiname></xref></p></li> |
|
179 </ul><p>the examples implicitly use the templated classes:</p><p>Examples |
|
180 of APIs</p><ul> |
|
181 <li><p>CleanupDelete<class T></p></li> |
|
182 <li><p>CleanupClose<class T></p></li> |
|
183 <li><p>CleanupRelease<class T></p></li> |
|
184 <li><p>CleanupArrayDelete<class T></p></li> |
|
185 </ul> <p><b>Security issues</b> </p> <p>The example requires no specific capabilities |
|
186 in order to run - and does not demonstrate any security issues. </p> </section> |
|
187 </conbody></concept> |