Buffer abstraction.
More...
Buffer abstraction.
- Author
- Lorenzo Miniero loren.nosp@m.zo@m.nosp@m.eetec.nosp@m.ho.c.nosp@m.om
- Copyright
- MIT License
Abstraction of buffered data.
◆ 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
-
| buffer | Buffer to append the new data to |
| bytes | Data to append |
| length | Size 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
-
| bytes | The data to initialize the buffer with, if any |
| size | Size of the data, if any |
- Returns
- A pointer to a new imquic_buffer instance, if successful, or NULL otherwise
◆ imquic_buffer_destroy()
Destroy an existing buffer.
- Parameters
-
◆ 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
-
| buffer | Buffer to resize |
| new_size | New 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
-
| buffer | Buffer to update |
| length | How many bytes back the buffer should be moved |