From b042625d032ab9dbc0afd744da19bb25d96309f8 Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Sun, 23 Jun 2024 14:29:33 +0200 Subject: [PATCH] rb_push write space checking --- ringbuf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ringbuf.c b/ringbuf.c index 9c57e68..375b5d5 100644 --- a/ringbuf.c +++ b/ringbuf.c @@ -15,7 +15,7 @@ void rb_destroy(struct RingBuf *rb, int(free)(void *)) { free(rb->buffer); } enum WriteResult rb_push(struct RingBuf *rb, void *data[], int amount, int (*memcpy)(void *, const void *, int)) { - if (rb->write_idx == rb->read_idx) { + if (rb->write_idx + amount >= rb->capacity) { return CollisionError; }