|
ring_buf
|
Header file for ring buffer item functions. More...
#include "ring_buf.h"

Go to the source code of this file.
Typedefs | |
| typedef uint16_t | ring_buf_item_length_t |
| Size of the ring buffer's item length. | |
Functions | |
| int | ring_buf_item_put (struct ring_buf *buf, const void *item, ring_buf_item_length_t length) |
| Puts an item's length and content. | |
| int | ring_buf_item_get (struct ring_buf *buf, void *item, ring_buf_item_length_t *length) |
| Gets an item from a ring buffer. | |
Header file for ring buffer item functions.
This file contains the declarations for functions that handle putting and getting items in a ring buffer, where each item is prefixed with its length as a ring_buf_item_length_t 16-bit unsigned integer.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Definition in file ring_buf_item.h.
| typedef uint16_t ring_buf_item_length_t |
Size of the ring buffer's item length.
The length is the size of the item in bytes.
Definition at line 46 of file ring_buf_item.h.
| int ring_buf_item_get | ( | struct ring_buf * | buf, |
| void * | item, | ||
| ring_buf_item_length_t * | length | ||
| ) |
Gets an item from a ring buffer.
| buf | Address of the ring buffer. |
| item | Address of the item. Reserve sufficient space for the incoming bytes. There must be space for the largest possible item, since the largest one possible could be next. |
| length | Address of the length of the item on success. |
| 0 | on success. |
| -EAGAIN | if the buffer is empty. |
Definition at line 43 of file ring_buf_item.c.
| int ring_buf_item_put | ( | struct ring_buf * | buf, |
| const void * | item, | ||
| ring_buf_item_length_t | length | ||
| ) |
Puts an item's length and content.
| buf | Address of the ring buffer. |
| item | Address of item to put. |
| length | Number of bytes to put. |
| Zero | or greater on success, negative on error. |
| -EMSGSIZE | if the buffer has insufficient space to put the item's length and data. |
Definition at line 35 of file ring_buf_item.c.