Dynamic Buffers Overview

This document provides an overview of dynamic buffers.


Manipulates data buffers of variable length.

For fixed length data buffers, or buffers whose length does not vary much from a known maximum size, use descriptors rather than this API.


The API has three key concepts: dynamic buffer base, flat dynamic buffer, and segmented dynamic buffer.

Dynamic buffer base

The dynamic buffer base specifies a common interface to dynamic buffers. It provides operations to manage the buffer position, a byte offset into the buffer’s data. Clients use a buffer position to reference the buffer, rather than explicit pointers, which can become outdated when reallocations occur.

The dynamic buffer base interface is provided by the abstract class CBufBase.

Flat dynamic buffer

The flat dynamic buffer stores all data in a single contiguous memory area. A flat buffer is the most efficient choice when resizing the buffer beyond a certain maximum length is not expected often.

The flat dynamic buffer interface is provided by CBufFlat.

Segmented dynamic buffer

The segmented dynamic buffer can store data in multiple memory areas. They are to be preferred for very large amounts of data, and where resizing of the buffer is commonly expected.

The segmented dynamic buffer interface is provided by CBufSeg.