32 lines
750 B
C
32 lines
750 B
C
#ifndef CRT_RINGBUF_H
|
|
#define CRT_RINGBUF_H
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef struct crt_ringbuf crt_ringbuf_t;
|
|
|
|
crt_ringbuf_t* crt_ringbuf_create(size_t capacity);
|
|
void crt_ringbuf_destroy(crt_ringbuf_t* rb);
|
|
|
|
bool crt_ringbuf_push(crt_ringbuf_t* rb, const void* data, size_t len);
|
|
bool crt_ringbuf_pop(crt_ringbuf_t* rb, void* out, size_t* len);
|
|
bool crt_ringbuf_peek(crt_ringbuf_t* rb, void* out, size_t* len);
|
|
|
|
size_t crt_ringbuf_count(crt_ringbuf_t* rb);
|
|
size_t crt_ringbuf_capacity(crt_ringbuf_t* rb);
|
|
bool crt_ringbuf_empty(crt_ringbuf_t* rb);
|
|
bool crt_ringbuf_full(crt_ringbuf_t* rb);
|
|
void crt_ringbuf_clear(crt_ringbuf_t* rb);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|