Electroneum
sldns_buffer Struct Reference

#include <sbuffer.h>

Collaboration diagram for sldns_buffer:

Public Attributes

size_t _position
 
size_t _limit
 
size_t _capacity
 
uint8_t_data
 
unsigned _fixed: 1
 
unsigned _vfixed: 1
 
unsigned _status_err: 1
 

Detailed Description

implementation of buffers to ease operations

sldns_buffers can contain arbitrary information, per octet. You can write to the current end of a buffer, read from the current position, and access any data within it.

Definition at line 116 of file sbuffer.h.

Member Data Documentation

◆ _capacity

size_t sldns_buffer::_capacity

The amount of data the buffer can contain

Definition at line 125 of file sbuffer.h.

◆ _data

uint8_t* sldns_buffer::_data

The data contained in the buffer

Definition at line 128 of file sbuffer.h.

◆ _fixed

unsigned sldns_buffer::_fixed

If the buffer is fixed it cannot be resized

Definition at line 131 of file sbuffer.h.

◆ _limit

size_t sldns_buffer::_limit

The read/write limit

Definition at line 122 of file sbuffer.h.

◆ _position

size_t sldns_buffer::_position

The current position used for reading/writing

Definition at line 119 of file sbuffer.h.

◆ _status_err

unsigned sldns_buffer::_status_err

The current state of the buffer. If writing to the buffer fails for any reason, this value is changed. This way, you can perform multiple writes in sequence and check for success afterwards.

Definition at line 147 of file sbuffer.h.

◆ _vfixed

unsigned sldns_buffer::_vfixed

If the buffer is vfixed, no more than capacity bytes willl be written to _data, however the _position counter will be updated with the amount that would have been written in consecutive writes. This allows for a modus operandi in which a sequence is written on a fixed capacity buffer (perhaps with _data on stack). When everything could be written, then the _data is immediately usable, if not, then a buffer could be allocated sized precisely to fit the data for a second attempt.

Definition at line 142 of file sbuffer.h.


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