Description of flat and segmented buffers in Symbian platform.
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:
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 (TBuf) may be used for this.
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 TBuf: programming is simple, and only a little memory is wasted
if the data is of significantly varying length, the memory can be allocated on the heap, and the allocation extended when necessary. The CBufFlat class is provided to manage this
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 CBufSeg class is provided to manage this
Symbian platform provides flat buffers, objects of type CBufFlat, which are used to allocate and manage storage in a single allocated cell
Symbian platform provides segmented buffers, objects of type CBufSeg, which are used to allocate and manage storage in several alloc cells.
Both types of buffer have a common base class, CBufBase. 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.
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.