libsignal-protocol-c  master
ProtobufCBufferSimple Struct Reference

#include <protobuf-c.h>

Collaboration diagram for ProtobufCBufferSimple:

Public Attributes

ProtobufCBuffer base
 
size_t alloced
 
size_t len
 
uint8_t * data
 
protobuf_c_boolean must_free_data
 
ProtobufCAllocatorallocator
 

Detailed Description

Simple buffer "subclass" of ProtobufCBuffer.

A ProtobufCBufferSimple object is declared on the stack and uses a scratch buffer provided by the user for the initial allocation. It performs exponential resizing, using dynamically allocated memory. A ProtobufCBufferSimple object can be created and used as follows:

uint8_t pad[128];
ProtobufCBuffer *buffer = (ProtobufCBuffer *) &simple;

buffer can now be used with protobuf_c_message_pack_to_buffer(). Once a message has been serialized to a ProtobufCBufferSimple object, the serialized data bytes can be accessed from the .data field.

To free the memory allocated by a ProtobufCBufferSimple object, if any, call PROTOBUF_C_BUFFER_SIMPLE_CLEAR() on the object, for example:

See also
PROTOBUF_C_BUFFER_SIMPLE_INIT
PROTOBUF_C_BUFFER_SIMPLE_CLEAR

Member Data Documentation

◆ allocator

ProtobufCAllocator* ProtobufCBufferSimple::allocator

Allocator to use. May be NULL to indicate the system allocator.

◆ alloced

size_t ProtobufCBufferSimple::alloced

Number of bytes allocated in data.

◆ base

ProtobufCBuffer ProtobufCBufferSimple::base

"Base class".

◆ data

uint8_t* ProtobufCBufferSimple::data

Data bytes.

◆ len

size_t ProtobufCBufferSimple::len

Number of bytes currently stored in data.

◆ must_free_data

protobuf_c_boolean ProtobufCBufferSimple::must_free_data

Whether data must be freed.


The documentation for this struct was generated from the following file: