aboutsummaryrefslogtreecommitdiff
path: root/ring-buffer.h
blob: cfd70e0fc9775347306b3b1ade441cf8c924c0aa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#ifndef RING_BUFFER_H
#define RING_BUFFER_H

#include <stdbool.h>
#include <stddef.h>

/*
 * Circular buffer with functions for accessing elements in order.
 * One slot always remains unused to distinguish between the empty/full case.
 */

typedef struct RingBuffer RingBuffer;

RingBuffer *ringbuf_alloc(size_t size);
void ringbuf_free(RingBuffer*);
void ringbuf_add(RingBuffer*, const void *value);
const void *ringbuf_prev(RingBuffer*);
const void *ringbuf_next(RingBuffer*);
void ringbuf_invalidate(RingBuffer*);

#endif