Symbian3/SDK/Source/GUID-6468F3CB-7828-5746-A868-AD525EB7D6BD.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Tue, 20 Jul 2010 12:00:49 +0100
changeset 13 48780e181b38
parent 0 89d6a7a84779
permissions -rw-r--r--
Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.

<?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-6468F3CB-7828-5746-A868-AD525EB7D6BD" xml:lang="en"><title>Introduction
to dynamic buffers</title><shortdesc>Description of flat and segmented buffers in Symbian platform.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>A buffer is an area of memory which may contain data. Managing data in
buffers can be more or less complex, depending on the requirements:</p>
<ul>
<li id="GUID-2892A824-D918-5998-9730-B780BBDE254C"><p>if the data is of fixed
length, a fixed-length area of memory may be allocated, either on the stack
or the heap; a buffer descriptor (<codeph>TBuf</codeph>) may be used for this.</p> </li>
<li id="GUID-22EC8B3D-2230-597D-935D-37A5DBCF1094"><p>if the data is of varying
length, but the variation is relatively small, it may still be appropriate
to allocate the data within a non-extensible buffer such as <codeph>TBuf</codeph>:
programming is simple, and only a little memory is wasted</p> </li>
<li id="GUID-75E026E3-8C69-575C-A893-1A41192E9073"><p>if the data is of significantly
varying length, the memory can be allocated on the heap, and the allocation
extended when necessary. The <codeph>CBufFlat</codeph> class is provided to
manage this</p> </li>
<li id="GUID-C4B11D3C-A514-56FE-AAB1-24D658CDF921"><p>if the data’s length
varies so much that a single heap cell cannot reasonably be expected to hold
it all, then the data must be held in several heap cells, but these must appear
as one for convenience. The <codeph>CBufSeg</codeph> class is provided to
manage this</p> </li>
</ul>
<p>Symbian platform provides <i>flat buffers</i>, objects of type <codeph>CBufFlat</codeph>,
which are used to allocate and manage storage in a single allocated cell</p>
<p>Symbian platform provides <i>segmented buffers</i>, objects of type <codeph>CBufSeg</codeph>,
which are used to allocate and manage storage in several alloc cells.</p>
<p>Both types of buffer have a common base class, <codeph>CBufBase</codeph>.
This class specifies the main aspects of the programming interface. Having
a common base class allows the decision as to whether to use flat or segmented
buffers to be changed during program development, with minimal impact on code.</p>
</conbody></concept>