src/util/circle-buffer.h (view raw)
1#ifndef CIRCLE_BUFFER_H
2#define CIRCLE_BUFFER_H
3
4#include "util/common.h"
5
6struct CircleBuffer {
7 void* data;
8 size_t capacity;
9 size_t size;
10 void* readPtr;
11 void* writePtr;
12};
13
14void CircleBufferInit(struct CircleBuffer* buffer, unsigned capacity);
15void CircleBufferDeinit(struct CircleBuffer* buffer);
16size_t CircleBufferSize(const struct CircleBuffer* buffer);
17size_t CircleBufferCapacity(const struct CircleBuffer* buffer);
18void CircleBufferClear(struct CircleBuffer* buffer);
19int CircleBufferWrite8(struct CircleBuffer* buffer, int8_t value);
20int CircleBufferWrite32(struct CircleBuffer* buffer, int32_t value);
21int CircleBufferRead8(struct CircleBuffer* buffer, int8_t* value);
22int CircleBufferRead32(struct CircleBuffer* buffer, int32_t* value);
23size_t CircleBufferRead(struct CircleBuffer* buffer, void* output, size_t length);
24size_t CircleBufferDump(const struct CircleBuffer* buffer, void* output, size_t length);
25
26#endif