DataBuffer

Description

DataBuffer manages a block of memory that data is appended to piece by piece. The buffer tracks its own current length, so each append copies the new data straight to the end. strcat, by contrast, searches for the end of the existing string on every call. Because appends are byte copies, the data can be of any type, not only strings.

Use Cases

  • Concatenating many strings into one message efficiently
  • Assembling binary data (structures, arrays, raw bytes) into a single contiguous block, for example a packet to be sent over a network

Overview

  • Usage
  • Initializing a buffer, appending data, and reading the result

  • Functions
  • Initializing, appending to, and clearing a buffer

  • Types and Enums
  • The buffer structure and error codes