aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrille Henry <nusmuk@users.sourceforge.net>2005-05-30 16:55:33 +0000
committerIOhannes m zmölnig <zmoelnig@iem.at>2015-10-14 13:53:22 +0200
commit7fc71ea46f7424a15cf39d0be2b9525fa6d5a1f0 (patch)
tree2a5ccff99beebaabe509a8360e0919c38a12ed0b
parentb482058421cce60ced22afcbba3354052e417c7c (diff)
bugfix of the lifo objects.
svn path=/trunk/externals/maxlib/; revision=3097
-rw-r--r--src/lifo.c24
1 files 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"));