From 7fc71ea46f7424a15cf39d0be2b9525fa6d5a1f0 Mon Sep 17 00:00:00 2001 From: Cyrille Henry Date: Mon, 30 May 2005 16:55:33 +0000 Subject: bugfix of the lifo objects. svn path=/trunk/externals/maxlib/; revision=3097 --- src/lifo.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/lifo.c b/src/lifo.c index beb0eda..b64f18d 100644 --- a/src/lifo.c +++ b/src/lifo.c @@ -33,7 +33,7 @@ typedef struct lifo { t_object d_ob; t_float *getal; - t_int count, end, size, teller; + t_int size, teller; t_outlet *out; }t_lifo; @@ -41,19 +41,23 @@ typedef struct lifo static t_class *lifo_class; static void lifo_int(t_lifo *x, t_floatarg n) -{ - x->getal[x->count] = n; - x->end = x->count; - if (x->teller < x->size) x->teller++; - x->count = (x->count + 1) % x->size; +{ + if(x->teller < x->size ) + { + x->getal[x->teller] = n; + x->teller++; + } + else + post("no more lifo memory"); + } static void lifo_bang(t_lifo *x) { - if (x->teller > 0){ - outlet_float(x->out,x->getal[x->end]); + if (x->teller > 0) + { + outlet_float(x->out,x->getal[x->teller-1]); x->teller--; - x->end = (x->end + x->size - 1) % x->size; } } @@ -74,8 +78,6 @@ static void *lifo_new(t_floatarg n) if (n<10) n = 10; x->size = (t_int)n; x->teller = 0; - x->end = 0; - x->count = 0; x->getal = (t_float *)getbytes(x->size * sizeof(t_float)); x->out = outlet_new(&x->d_ob, gensym("float")); -- cgit v1.2.1