Symbian3/PDK/Source/GUID-DD3411FE-D95B-5153-8C90-442618920E20.dita
changeset 1 25a17d01db0c
child 3 46218c8b8afa
equal deleted inserted replaced
0:89d6a7a84779 1:25a17d01db0c
       
     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-DD3411FE-D95B-5153-8C90-442618920E20" xml:lang="en"><title>How
       
    13 to reserve space in a fixed flat array</title><shortdesc>To be sure that there is sufficient space available to add new
       
    14 elements to a fixed flat array, you can use the <codeph>SetReserveL()</codeph> function
       
    15 to pre-allocate memory.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    16 <p>When adding elements to a flat array of elements having the same length
       
    17 (a <codeph>CArrayFixFlat&lt;class T&gt;</codeph> type) the array buffer may be
       
    18 re-allocated to accommodate the extra elements. This can fail for lack of
       
    19 memory.</p>
       
    20 <p>If it is important to guarantee that the process of inserting elements
       
    21 cannot fail at the time of insertion, then the necessary space in the array
       
    22 buffer should be reserved in advance. This allows any out of memory situation
       
    23 to be handled before starting to add elements to the array.</p>
       
    24 <p><codeph>SetReserveL()</codeph> reserves sufficient space to accommodate
       
    25 the required number of elements, in this case ten. </p>
       
    26 <codeblock id="GUID-CF5FED7D-52D9-5247-8E25-DDD5813474E4" xml:space="preserve">CArrayFixFlat&lt;TElement&gt;* fixflat;
       
    27 fixflat = new (ELeave) CArrayFixFlat&lt;TElement&gt;(3);
       
    28 ...
       
    29 fixflat-&gt;SetReserveL(10);</codeblock>
       
    30 <p>If the array already contains five elements, then another five elements
       
    31 can be added to the array and be guaranteed not to fail for lack of memory.</p>
       
    32 </conbody></concept>