Loading...
Searching...
No Matches
buffer.h File Reference

Buffer abstraction (headers) More...

#include <stdint.h>
#include <glib.h>
Include dependency graph for buffer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  imquic_buffer
 Internal buffer. More...

Typedefs

typedef struct imquic_buffer imquic_buffer
 Internal buffer.

Functions

imquic_bufferimquic_buffer_create (uint8_t *bytes, uint64_t size)
 Create a new buffer.
gboolean imquic_buffer_resize (imquic_buffer *buffer, uint64_t new_size)
 Resize an existing buffer.
int imquic_buffer_append (imquic_buffer *buffer, uint8_t *bytes, uint64_t length)
 Append data at the end of the buffer.
void imquic_buffer_shift (imquic_buffer *buffer, uint64_t length)
 Move the data in the buffer back of a specific number of bytes.
void imquic_buffer_destroy (imquic_buffer *buffer)
 Destroy an existing buffer.

Detailed Description

Buffer abstraction (headers)

Author
Lorenzo Miniero loren.nosp@m.zo@m.nosp@m.eetec.nosp@m.ho.c.nosp@m.om

Abstraction of buffered data.

Typedef Documentation

◆ imquic_buffer

typedef struct imquic_buffer imquic_buffer

Internal buffer.

Function Documentation

◆ imquic_buffer_append()

int imquic_buffer_append ( imquic_buffer * buffer,
uint8_t * bytes,
uint64_t length )

Append data at the end of the buffer.

Note
This automatically resizes the buffer with imquic_buffer_resize, if appending the new data would exceeds the buffer size.
Parameters
bufferBuffer to append the new data to
bytesData to append
lengthSize of the data to append returns 0 if successful, a negative integer otherwise

◆ imquic_buffer_create()

imquic_buffer * imquic_buffer_create ( uint8_t * bytes,
uint64_t size )

Create a new buffer.

Note
Passing empty data will only allocate an empty buffer instance that can be updated/expanded later on.
Parameters
bytesThe data to initialize the buffer with, if any
sizeSize of the data, if any
Returns
A pointer to a new imquic_buffer instance, if successful, or NULL otherwise

◆ imquic_buffer_destroy()

void imquic_buffer_destroy ( imquic_buffer * buffer)

Destroy an existing buffer.

Parameters
bufferBuffer to destroy

◆ imquic_buffer_resize()

gboolean imquic_buffer_resize ( imquic_buffer * buffer,
uint64_t new_size )

Resize an existing buffer.

Note
We can only increase the size of the buffer, not reduce it.
Parameters
bufferBuffer to resize
new_sizeNew size of the buffer
Returns
TRUE if successful, FALSE otherwise

◆ imquic_buffer_shift()

void imquic_buffer_shift ( imquic_buffer * buffer,
uint64_t length )

Move the data in the buffer back of a specific number of bytes.

Note
This automatically updates the buffer length accordingly.
Parameters
bufferBuffer to update
lengthHow many bytes back the buffer should be moved