Compare commits
No commits in common. "41f817fd5b7d3f9adbb9ce47c511d95fd1f7b7b8" and "db38111b3cc68a00514fc7e6601ad41d1e2b34d0" have entirely different histories.
41f817fd5b
...
db38111b3c
2 changed files with 6 additions and 23 deletions
|
@ -45,14 +45,6 @@ rb_destroy(struct RingBuf *rb, void(free)())
|
||||||
free(rb->buffer);
|
free(rb->buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
rb_clear(struct RingBuf *rb)
|
|
||||||
{
|
|
||||||
rb->count = 0;
|
|
||||||
rb->write_head = rb->buffer;
|
|
||||||
rb->read_head = rb->buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
enum WriteResult
|
enum WriteResult
|
||||||
rb_push_back(struct RingBuf *rb, const void *item, MEMCPY_T memcpy_fn)
|
rb_push_back(struct RingBuf *rb, const void *item, MEMCPY_T memcpy_fn)
|
||||||
{
|
{
|
||||||
|
|
21
ringbuf.h
21
ringbuf.h
|
@ -39,14 +39,6 @@ enum ReadResult { Empty, ReadOk }; /** Result of a read */
|
||||||
void rb_init(struct RingBuf *rb, rb_size_t capacity, ALLOC_T alloc,
|
void rb_init(struct RingBuf *rb, rb_size_t capacity, ALLOC_T alloc,
|
||||||
rb_size_t struct_size);
|
rb_size_t struct_size);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Clear the ring buffer
|
|
||||||
* @details This function will reset the read and write heads to the beginning
|
|
||||||
* of the buffer, and set the count to 0. It will not free the buffer.
|
|
||||||
* @param rb The ring buffer
|
|
||||||
*/
|
|
||||||
void rb_clear(struct RingBuf *rb);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Insert data to the ring buffer
|
* @brief Insert data to the ring buffer
|
||||||
* @param rb The ring buffer
|
* @param rb The ring buffer
|
||||||
|
@ -59,17 +51,17 @@ enum WriteResult rb_push_back(struct RingBuf *rb, const void *item,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Insert multiple data to the ring buffer
|
* @brief Insert multiple data to the ring buffer
|
||||||
*
|
*
|
||||||
* @details This function is more efficient than calling rb_push_back multiple
|
* @details This function is more efficient than calling rb_push_back multiple
|
||||||
* times. It only advances the write head once, and attempts to write all the
|
* times. It only advances the write head once, and attempts to write all the
|
||||||
* memory in one go.
|
* memory in one go.
|
||||||
*
|
*
|
||||||
* If n is greater than the capacity, it will return Full.
|
* If n is greater than the capacity, it will return Full.
|
||||||
* If the full write will overflow, it will wrap around.
|
* If the full write will overflow, it will wrap around.
|
||||||
*
|
*
|
||||||
* If the buffer is full, it will return Full and not write
|
* If the buffer is full, it will return Full and not write
|
||||||
* anything.
|
* anything.
|
||||||
*
|
*
|
||||||
* @param rb The ring buffer
|
* @param rb The ring buffer
|
||||||
* @param items The items to insert
|
* @param items The items to insert
|
||||||
* @param memcpy_fn The memcpy function
|
* @param memcpy_fn The memcpy function
|
||||||
|
@ -85,8 +77,7 @@ enum WriteResult rb_push_many(struct RingBuf *rb, const void *items,
|
||||||
* @param item The item to read into
|
* @param item The item to read into
|
||||||
* @return ReadResult
|
* @return ReadResult
|
||||||
*/
|
*/
|
||||||
enum ReadResult rb_pop_front(struct RingBuf *rb, void *item,
|
enum ReadResult rb_pop_front(struct RingBuf *rb, void *item, MEMCPY_T memcpy_fn);
|
||||||
MEMCPY_T memcpy_fn);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Free the ring buffer
|
* @brief Free the ring buffer
|
||||||
|
|
Loading…
Reference in a new issue