Maintained by: NLnet Labs
Data Fields
sldns_buffer Struct Reference

implementation of buffers to ease operations More...

#include <sbuffer.h>

Data Fields

size_t _position
 The current position used for reading/writing.
 
size_t _limit
 The read/write limit.
 
size_t _capacity
 The amount of data the buffer can contain.
 
uint8_t * _data
 The data contained in the buffer.
 
unsigned _fixed: 1
 If the buffer is fixed it cannot be resized.
 
unsigned _vfixed: 1
 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. More...
 
unsigned _status_err: 1
 The current state of the buffer. More...
 

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.

Field Documentation

◆ _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.

Referenced by sldns_buffer_at(), sldns_buffer_init_frm_data(), sldns_buffer_init_vfixed_frm_data(), sldns_buffer_new(), sldns_buffer_new_frm_data(), sldns_buffer_set_at(), sldns_buffer_set_position(), sldns_buffer_skip(), sldns_buffer_write_at(), sldns_buffer_write_u16_at(), sldns_buffer_write_u32_at(), sldns_buffer_write_u48_at(), and sldns_buffer_write_u8_at().

◆ _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.

Referenced by sldns_buffer_new(), sldns_buffer_new_frm_data(), and sldns_buffer_status().


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