Loading...
Searching...
No Matches
buffer.h
Go to the documentation of this file.
1
14#ifndef IMQUIC_BUFFER_H
15#define IMQUIC_BUFFER_H
16
17#include <stdint.h>
18
19#include <glib.h>
20
22typedef struct imquic_buffer_chunk {
24 uint8_t *data;
26 uint64_t offset;
28 uint64_t length;
33
35typedef struct imquic_buffer {
38 uint64_t stream_id;
40 GList *chunks;
42 uint64_t base_offset;
47imquic_buffer *imquic_buffer_create(uint64_t stream_id);
51
59int imquic_buffer_put(imquic_buffer *buf, uint8_t *data, uint64_t offset, uint64_t length);
65int imquic_buffer_append(imquic_buffer *buf, uint8_t *data, uint64_t length);
86
90void imquic_buffer_print(int level, imquic_buffer *buf);
91
92#endif
imquic_buffer * imquic_buffer_create(uint64_t stream_id)
Helper method to create a new buffer.
Definition buffer.c:17
void imquic_buffer_chunk_free(imquic_buffer_chunk *chunk)
Helper to quickly free a buffer chunk.
Definition buffer.c:31
struct imquic_buffer_chunk imquic_buffer_chunk
Buffer chunk.
imquic_buffer_chunk * imquic_buffer_peek(imquic_buffer *buf)
Helper method to peek at a buffer and check if there's data to read.
Definition buffer.c:121
void imquic_buffer_print(int level, imquic_buffer *buf)
Helper method to print the contents of a buffer.
Definition buffer.c:142
void imquic_buffer_destroy(imquic_buffer *buf)
Helper method to destroy an existing buffer.
Definition buffer.c:23
int imquic_buffer_put(imquic_buffer *buf, uint8_t *data, uint64_t offset, uint64_t length)
Helper method to add new data to the buffer at a specific offset, as a new chunk.
Definition buffer.c:39
struct imquic_buffer imquic_buffer
Buffer made of multiple chunks (possibly with gaps)
int imquic_buffer_append(imquic_buffer *buf, uint8_t *data, uint64_t length)
Helper method to add new data at the end of the buffer, as a new chunk.
Definition buffer.c:100
imquic_buffer_chunk * imquic_buffer_get(imquic_buffer *buf)
Helper method to get a chunk of data from the buffer.
Definition buffer.c:132
Buffer chunk.
Definition buffer.h:22
uint8_t * data
Data in this buffer chunk.
Definition buffer.h:24
uint64_t length
Size of this this buffer chunk.
Definition buffer.h:28
uint64_t offset
Offset this data is in, in the overall overall buffer.
Definition buffer.h:26
Buffer made of multiple chunks (possibly with gaps)
Definition buffer.h:35
uint64_t base_offset
Offset in the buffer to start from, when reading chunks from the buffer.
Definition buffer.h:42
GList * chunks
Ordered list of chunks in this buffer.
Definition buffer.h:40
uint64_t stream_id
Stream ID this buffer is associated with.
Definition buffer.h:38