#include <stdbool.h>
#include <stddef.h>
Go to the source code of this file.
Functions | |
| struct fifo_buffer * | fifo_buffer_new (size_t size) |
| Creates a new fifo_buffer object. | |
| void | fifo_buffer_free (struct fifo_buffer *buffer) |
| Frees the resources consumed by this fifo_buffer object. | |
| void | fifo_buffer_clear (struct fifo_buffer *buffer) |
| Clears all data currently in this fifo_buffer object. | |
| const void * | fifo_buffer_read (const struct fifo_buffer *buffer, size_t *length_r) |
| Reads from the beginning of the buffer. | |
| void | fifo_buffer_consume (struct fifo_buffer *buffer, size_t length) |
| Marks data at the beginning of the buffer as "consumed". | |
| void * | fifo_buffer_write (struct fifo_buffer *buffer, size_t *max_length_r) |
| Prepares writing to the buffer. | |
| void | fifo_buffer_append (struct fifo_buffer *buffer, size_t length) |
| Commits the write operation initiated by fifo_buffer_write(). | |
| bool | fifo_buffer_is_empty (struct fifo_buffer *buffer) |
| Checks if the buffer is empty. | |
| bool | fifo_buffer_is_full (struct fifo_buffer *buffer) |
| Checks if the buffer is full. | |
You may append data at the end, while another instance reads data from the beginning. It is optimized for zero-copy usage: you get pointers to the real buffer, where you may operate on.
This library is not thread safe.
Definition in file fifo_buffer.h.
| void fifo_buffer_append | ( | struct fifo_buffer * | buffer, | |
| size_t | length | |||
| ) |
Commits the write operation initiated by fifo_buffer_write().
| buffer | the fifo_buffer object | |
| length | the number of bytes which were written |
| void fifo_buffer_clear | ( | struct fifo_buffer * | buffer | ) |
Clears all data currently in this fifo_buffer object.
This does not overwrite the actuall buffer; it just resets the internal pointers.
| void fifo_buffer_consume | ( | struct fifo_buffer * | buffer, | |
| size_t | length | |||
| ) |
Marks data at the beginning of the buffer as "consumed".
| buffer | the fifo_buffer object | |
| length | the number of bytes which were consumed |
| void fifo_buffer_free | ( | struct fifo_buffer * | buffer | ) |
Frees the resources consumed by this fifo_buffer object.
| bool fifo_buffer_is_empty | ( | struct fifo_buffer * | buffer | ) |
Checks if the buffer is empty.
| bool fifo_buffer_is_full | ( | struct fifo_buffer * | buffer | ) |
Checks if the buffer is full.
| struct fifo_buffer* fifo_buffer_new | ( | size_t | size | ) | [read] |
Creates a new fifo_buffer object.
Free this object with fifo_buffer_free().
| size | the size of the buffer in bytes |
| const void* fifo_buffer_read | ( | const struct fifo_buffer * | buffer, | |
| size_t * | length_r | |||
| ) |
Reads from the beginning of the buffer.
To remove consumed data from the buffer, call fifo_buffer_consume().
| buffer | the fifo_buffer object | |
| length_r | the maximum amount to read is returned here |
| void* fifo_buffer_write | ( | struct fifo_buffer * | buffer, | |
| size_t * | max_length_r | |||
| ) |
Prepares writing to the buffer.
This returns a buffer which you can write to. To commit the write operation, call fifo_buffer_append().
| buffer | the fifo_buffer object | |
| max_length_r | the maximum amount to write is returned here |
1.5.9