Symbian3/PDK/Source/GUID-D664843A-0741-5E38-88D0-D8BEC9C732EB.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Thu, 11 Mar 2010 18:02:22 +0000
changeset 3 46218c8b8afa
parent 1 25a17d01db0c
child 5 f345bda72bc4
permissions -rw-r--r--
week 10 bug fix submission (SF PDK version): Bug 1892, Bug 1897, Bug 1319. Also 3 or 4 documents were found to contain code blocks with SFL, which has been fixed. Partial fix for broken links, links to Forum Nokia, and the 'Symbian platform' terminology issues.

<?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-D664843A-0741-5E38-88D0-D8BEC9C732EB" xml:lang="en"><title>How
to destroy the array</title><shortdesc>Simple arrays can be simply deleted. Certain arrays of pointers
may require calling a member function to delete the objects pointed to.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>If an array consists of <codeph>T</codeph> or <codeph>R</codeph> type elements,
it can be destroyed by simply deleting it:</p>
<codeblock id="GUID-DD031059-EB7F-5767-95EB-01D9715214DF" xml:space="preserve">delete array;</codeblock>
<p>Where the array is either a <codeph>CArrayPtrFlat</codeph> or <codeph>CArrayPtrSeg</codeph> object
and the elements are pointers to <codeph>CBase</codeph> derived objects, then
these objects should first be destroyed by calling the <codeph>ResetAndDestroy()</codeph> member
function:</p>
<codeblock id="GUID-FAFAE1AE-CCE3-5B5B-95A0-BAC900706C19" xml:space="preserve">array-&gt;ResetAndDestroy();
delete array;</codeblock>
<section id="GUID-16F6086C-6072-447A-BFE5-C3C4869033BF"><title>Notes</title> <ul>
<li id="GUID-84F5B547-631E-5FD5-8C3B-736BEB2A94FB"><p>The <codeph>RArray&lt;class T&gt;</codeph> and <codeph>RPointerArray&lt;class T&gt;</codeph> types
are normally allocated on the program stack and are not deleted. However,
their array buffers <i>are</i> allocated on the heap and it is important that
these arrays are handled correctly to avoid memory leaks.</p> </li>
<li id="GUID-98A2BC12-BEC2-5C29-93A1-51531D5F5063"><p>As a minimum, their <codeph>Close()</codeph> functions
must be called before the arrays go out of scope. Additionally, for the <codeph>RPointerArray&lt;class T&gt;</codeph> type,
the <codeph>ResetAndDestroy()</codeph> function may be called if the objects
represented by the array need to be deleted before the array goes out of scope.</p> </li>
</ul> </section>
</conbody></concept>