aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fifop.c23
-rw-r--r--src/lifop.c27
2 files changed, 19 insertions, 31 deletions
diff --git a/src/fifop.c b/src/fifop.c
index b9cecb0..308724c 100644
--- a/src/fifop.c
+++ b/src/fifop.c
@@ -44,7 +44,6 @@ typedef struct _fifop_prioritylist {
t_fifop_list *fifo_start;
t_fifop_list *fifo_end;
struct _fifop_prioritylist *next;
- unsigned long counter;
} t_fifop_prioritylist;
typedef struct _fifop
@@ -52,6 +51,7 @@ typedef struct _fifop
t_object x_obj;
t_fifop_prioritylist *fifo_list;
t_float priority; /* current priority */
+ unsigned long counter;
t_outlet *x_out, *x_infout;
} t_fifop;
@@ -83,7 +83,6 @@ static t_fifop_prioritylist*fifop_genprioritylist(t_fifop*x, t_float priority)
result->fifo_start=0;
result->fifo_end=0;
result->next=0;
- result->counter=0;
/* insert it into the list of priority lists */
if(dummy==0){
@@ -139,7 +138,6 @@ static int add2fifo(t_fifop_prioritylist*fifoprio, int argc, t_atom *argv)
/* and at the same time, it is the last entry */
fifoprio->fifo_end =entry;
}
- fifoprio->counter++;
return 0;
}
static t_fifop_prioritylist*getFifo(t_fifop_prioritylist*pfifo)
@@ -157,7 +155,10 @@ static void fifop_list(t_fifop *x, t_symbol *s, int argc, t_atom *argv)
error("[fifop]: couldn't get priority fifo");
return;
}
- add2fifo(pfifo, argc, argv);
+ if(!add2fifo(pfifo, argc, argv))
+ {
+ x->counter++;
+ }
}
static void fifop_bang(t_fifop *x)
{
@@ -175,7 +176,7 @@ static void fifop_bang(t_fifop *x)
return;
}
- pfifo->counter--;
+ x->counter--;
pfifo->fifo_start=fifo->next;
if(0==pfifo->fifo_start){
@@ -200,17 +201,9 @@ static void fifop_bang(t_fifop *x)
}
static void fifop_query(t_fifop*x)
{
- unsigned long counter=0;
- t_fifop_prioritylist*pfifo=x->fifo_list;
-
- while(pfifo!=NULL){
- counter+=pfifo->counter;
- pfifo=pfifo->next;
- }
-
- verbose(1, "%d elements in fifo", (int)counter);
+ verbose(1, "%d elements in fifo", (int)x->counter);
- outlet_float(x->x_infout, (t_float)counter);
+ outlet_float(x->x_infout, (t_float)x->counter);
}
static void fifop_free(t_fifop *x)
{
diff --git a/src/lifop.c b/src/lifop.c
index 50df504..941ff7d 100644
--- a/src/lifop.c
+++ b/src/lifop.c
@@ -43,12 +43,12 @@ typedef struct _lifop_prioritylist {
t_float priority;
t_lifop_list *lifo_start;
struct _lifop_prioritylist *next;
- unsigned long counter;
} t_lifop_prioritylist;
typedef struct _lifop
{
t_object x_obj;
t_lifop_prioritylist *lifo_list;
+ unsigned long counter;
t_float priority; /* current priority */
t_outlet *x_out, *x_infout;
} t_lifop;
@@ -78,7 +78,6 @@ static t_lifop_prioritylist*lifop_genprioritylist(t_lifop*x, t_float priority)
result = (t_lifop_prioritylist*)getbytes(sizeof( t_lifop_prioritylist));
result->priority=priority;
result->lifo_start=0;
- result->counter=0;
/* insert it into the list of priority lists */
if(dummy==0){
@@ -122,7 +121,6 @@ static int add2lifo(t_lifop_prioritylist*lifoprio, int argc, t_atom *argv)
entry->next=lifoprio->lifo_start;
lifoprio->lifo_start=entry;
- lifoprio->counter++;
return 0;
}
@@ -141,7 +139,11 @@ static void lifop_list(t_lifop *x, t_symbol *s, int argc, t_atom *argv)
error("[lifop]: couldn't get priority lifo");
return;
}
- add2lifo(plifo, argc, argv);
+ if(!add2lifo(plifo, argc, argv))
+ {
+ x->counter++;
+ }
+
}
static void lifop_bang(t_lifop *x)
{
@@ -159,7 +161,7 @@ static void lifop_bang(t_lifop *x)
return;
}
- plifo->counter--;
+ x->counter--;
plifo->lifo_start=lifo->next;
@@ -181,18 +183,10 @@ static void lifop_bang(t_lifop *x)
freebytes(argv, argc*sizeof(t_atom));
}
static void lifop_query(t_lifop*x)
-{
- unsigned long counter=0;
- t_lifop_prioritylist*plifo=x->lifo_list;
-
- while(plifo!=NULL){
- counter+=plifo->counter;
- plifo=plifo->next;
- }
-
- verbose(1, "%d elements in lifo", (int)counter);
+{
+ verbose(1, "%d elements in lifo", (int)x->counter);
- outlet_float(x->x_infout, (t_float)counter);
+ outlet_float(x->x_infout, (t_float)x->counter);
}
static void lifop_free(t_lifop *x)
{
@@ -234,6 +228,7 @@ static void *lifop_new(t_symbol *s, int argc, t_atom *argv)
x->lifo_list = 0;
x->priority=0;
+ x->counter=0;
return (x);
}