Symbian3/SDK/Source/GUID-D664843A-0741-5E38-88D0-D8BEC9C732EB.dita
changeset 7 51a74ef9ed63
parent 0 89d6a7a84779
equal deleted inserted replaced
6:43e37759235e 7:51a74ef9ed63
       
     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-D664843A-0741-5E38-88D0-D8BEC9C732EB" xml:lang="en"><title>How
       
    13 to destroy the array</title><shortdesc>Simple arrays can be simply deleted. Certain arrays of pointers
       
    14 may require calling a member function to delete the objects pointed to.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    15 <p>If an array consists of <codeph>T</codeph> or <codeph>R</codeph> type elements,
       
    16 it can be destroyed by simply deleting it:</p>
       
    17 <codeblock id="GUID-DD031059-EB7F-5767-95EB-01D9715214DF" xml:space="preserve">delete array;</codeblock>
       
    18 <p>Where the array is either a <codeph>CArrayPtrFlat</codeph> or <codeph>CArrayPtrSeg</codeph> object
       
    19 and the elements are pointers to <codeph>CBase</codeph> derived objects, then
       
    20 these objects should first be destroyed by calling the <codeph>ResetAndDestroy()</codeph> member
       
    21 function:</p>
       
    22 <codeblock id="GUID-FAFAE1AE-CCE3-5B5B-95A0-BAC900706C19" xml:space="preserve">array-&gt;ResetAndDestroy();
       
    23 delete array;</codeblock>
       
    24 <section id="GUID-16F6086C-6072-447A-BFE5-C3C4869033BF"><title>Notes</title> <ul>
       
    25 <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
       
    26 are normally allocated on the program stack and are not deleted. However,
       
    27 their array buffers <i>are</i> allocated on the heap and it is important that
       
    28 these arrays are handled correctly to avoid memory leaks.</p> </li>
       
    29 <li id="GUID-98A2BC12-BEC2-5C29-93A1-51531D5F5063"><p>As a minimum, their <codeph>Close()</codeph> functions
       
    30 must be called before the arrays go out of scope. Additionally, for the <codeph>RPointerArray&lt;class T&gt;</codeph> type,
       
    31 the <codeph>ResetAndDestroy()</codeph> function may be called if the objects
       
    32 represented by the array need to be deleted before the array goes out of scope.</p> </li>
       
    33 </ul> </section>
       
    34 </conbody></concept>