22 #ifndef RC_RING_BUFFER_H 23 #define RC_RING_BUFFER_H 41 #define RC_RINGBUF_INITIALIZER {\ 144 #endif // RC_RING_BUFFER_H rc_ringbuf_t rc_ringbuf_empty(void)
Returns an rc_ringbuf_t struct which is completely zero'd out with no memory allocated for it...
int rc_ringbuf_alloc(rc_ringbuf_t *buf, int size)
Allocates memory for a ring buffer and initializes an rc_ringbuf_t struct.
double rc_ringbuf_get_value(rc_ringbuf_t *buf, int position)
Fetches the float which is 'position' steps behind the last value added to the buffer.
struct rc_ringbuf_t rc_ringbuf_t
Struct containing state of a ringbuffer and pointer to dynamically allocated memory.
int initialized
flag indicating if memory has been allocated for the buffer
Definition: ring_buffer.h:38
int rc_ringbuf_free(rc_ringbuf_t *buf)
Frees the memory allocated for buffer buf.
double rc_ringbuf_std_dev(rc_ringbuf_t buf)
Returns the standard deviation of all values in the ring buffer.
Struct containing state of a ringbuffer and pointer to dynamically allocated memory.
Definition: ring_buffer.h:34
int rc_ringbuf_insert(rc_ringbuf_t *buf, double val)
Puts a new float into the ring buffer and updates the index accordingly.
int index
index of the most recently added value
Definition: ring_buffer.h:37
int size
number of elements the buffer can hold
Definition: ring_buffer.h:36
int rc_ringbuf_reset(rc_ringbuf_t *buf)
Sets all values in the buffer to 0.0f and sets the buffer index back to 0.
double * d
pointer to dynamically allocated data
Definition: ring_buffer.h:35