Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

GBuffer

The gbuffer_t structure is a flexible, dynamic buffer designed to handle data efficiently. It supports reading, writing, serialization, and other utility operations. gbuffer_t is commonly used in Yuneta to manage data streams, encode/decode information, and store dynamic content.

Source code in:


Structure Overview

The gbuffer_t structure includes the following key fields:

FieldDescription
refcountReference counter for memory management.
labelA user-defined label for identifying the buffer.
markA user-defined marker for specific positions in the buffer.
data_sizeThe size of the allocated memory for the buffer.
max_memory_sizeThe maximum size the buffer can grow to in memory.
tailWrite pointer indicating the end of the written data.
curpRead pointer indicating the current read position.
dataDynamically allocated memory containing the buffer’s data.

Key Features

1. Reference Counting

2. Dynamic Memory Management

3. Reading and Writing

4. Serialization and Encoding

5. Utility Functions


Core Operations

Reading

Writing

Utility

Serialization and Encoding


Benefits of gbuffer_t


Practical Applications

  1. Data Streams:

    • Manage incoming or outgoing data streams efficiently with dynamic resizing and memory tracking.

  2. Serialization:

    • Convert structured data to JSON or Base64 for storage or transmission.

  3. Buffering:

    • Temporarily store data for asynchronous processing or delayed reading.