oops, off by one error in circular buffer

master
Ahmet Inan 2012-09-15 16:22:50 +02:00
rodzic 25adda3d8c
commit cb5abfecd0
1 zmienionych plików z 2 dodań i 2 usunięć

Wyświetl plik

@ -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;
}