A ring buffer library for C. This library can be used when you want to save a certain amount of data and only care about the newest "x" amount of it.
Getting Started
Installing
Usage
get started.
Install like this.
This is the initializer function for the ring buffer. Call this once in the start of the code to initalize the buffer size. The second parameter is the "object name" of the buffer.
Puts data into the buffer one at a time. Send the data you want to store in the buffer as the first parameter and the name of the buffer in the second. If the buffer is full, the oldest data will be overwritten.
Gets data from the buffer one at a time. Will return the newest data and remove it. If ringbuffer_put() is used after ringbuffer_get(), then ringbuffer_put() will put the new data in the place where the ringbuffer_get() collected the last from.
Call this to empty the buffer. Everything will be deleted and ready to receive new data.
Prints the ring buffer data for verification or debug purposes.
Prints the relevant variables for verification or debug purposes.
- head
- tail
- nose
Examples.
If you want to contribute that's great! Send a pull request and I will review it.
- Marius C. K. Gulbrandsen
This project is licensed under the GNU license - see the LICENSE file for details
- Thanks to Stig Thomas reviewing the code.