From cb5abfecd0d87840a3c8153dc542011710ee95aa Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Sat, 15 Sep 2012 16:22:50 +0200 Subject: [PATCH] oops, off by one error in circular buffer --- buffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buffer.c b/buffer.c index e860467..8733d51 100644 --- a/buffer.c +++ b/buffer.c @@ -12,8 +12,8 @@ float *do_buffer(struct buffer *d, float input) { d->s[d->last0] = input; d->s[d->last1] = input; - d->last0 = (d->last0 - 1) < 0 ? d->len : d->last0 - 1; - d->last1 = (d->last1 - 1) < 0 ? d->len : d->last1 - 1; + d->last0 = (d->last0 - 1) < 0 ? d->len - 1 : d->last0 - 1; + d->last1 = (d->last1 - 1) < 0 ? d->len - 1 : d->last1 - 1; int last = d->last0 < d->last1 ? d->last0 : d->last1; return d->s + last; }