22 #ifndef RC_RING_BUFFER_H
23 #define RC_RING_BUFFER_H
41 #define RC_RINGBUF_INITIALIZER {\
int rc_ringbuf_alloc(rc_ringbuf_t *buf, int size)
Allocates memory for a ring buffer and initializes an rc_ringbuf_t struct.
Definition: ring_buffer.c:37
double rc_ringbuf_std_dev(rc_ringbuf_t buf)
Returns the standard deviation of all values in the ring buffer.
Definition: ring_buffer.c:144
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.
Definition: ring_buffer.c:121
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.
Definition: ring_buffer.c:30
int rc_ringbuf_insert(rc_ringbuf_t *buf, double val)
Puts a new float into the ring buffer and updates the index accordingly.
Definition: ring_buffer.c:99
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.
Definition: ring_buffer.c:81
int rc_ringbuf_free(rc_ringbuf_t *buf)
Frees the memory allocated for buffer buf.
Definition: ring_buffer.c:68
struct rc_ringbuf_t rc_ringbuf_t
Struct containing state of a ringbuffer and pointer to dynamically allocated memory.
Struct containing state of a ringbuffer and pointer to dynamically allocated memory.
Definition: ring_buffer.h:34
int index
index of the most recently added value
Definition: ring_buffer.h:37
double * d
pointer to dynamically allocated data
Definition: ring_buffer.h:35
int initialized
flag indicating if memory has been allocated for the buffer
Definition: ring_buffer.h:38
int size
number of elements the buffer can hold
Definition: ring_buffer.h:36