blob: ba37e0ebf9b323c12d20bd9ec49460f98d91f411 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
#ifndef CIRCULAR_BUFFER_H
#define CIRCULAR_BUFFER_H 1
#include <string.h>
struct circular_buffer {
size_t size, write, read, max_size;
char *data;
};
extern struct circular_buffer *cbuffer_new(size_t initial, size_t max);
extern void cbuffer_free(struct circular_buffer *buf);
extern int cbuffer_add_unsafe(struct circular_buffer *buf, const char *d, size_t d_len);
extern void cbuffer_remove_unsafe(struct circular_buffer *buf, size_t num);
extern size_t cbuffer_next_unsafe(struct circular_buffer *buf, char **start);
#endif
|