X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=int%2Fqueue.c;h=cbb91bc979dc54ca42ec900172fa3ddc6ab61bad;hb=HEAD;hp=35ae2fdf31ab08cf620edc2c8f40fa939a2c5956;hpb=9db87b545def5d31a64608f2eb082d915ad5efa4;p=vlp.git diff --git a/int/queue.c b/int/queue.c deleted file mode 100644 index 35ae2fd..0000000 --- a/int/queue.c +++ /dev/null @@ -1,112 +0,0 @@ -#include "depend.h" -#include "genint.h" -#include "int.h" -#include "process.h" -#include "intproto.h" - - -/* Queue management */ -/* Single linked circular lists with queue represented as pointer to rear */ - -queue qinit() /* Initialize empty queue */ -{ - return (NULL); -} /* end qinit */ - - -stack push(q, e) /* Insert element into the queue */ -stack q; -selem e; -{ - stack p; - - p = (stack) ballocate(sizeof(struct queuelem)); - if (p == NULL) errsignal(RTEMEMOV); - p->elem = e; - if (q == NULL) - { - p->next = p; /* the lonely element of the queue */ - q = p; - } - else - { - p->next = q->next; /* insert at rear */ - q->next = p; - } - return(q); -} /* end push */ - - -qelem qfront(q) /* Get first element of the queue */ -queue q; -{ - if (qempty(q)){ - fprintf( stderr, "getting first element from empty queue\n"); - errsignal(RTESYSER); - } - return (q->next->elem); -} /* end qfront */ - - -queue qremove(q) /* Remove front element from the queue */ -queue q; -{ - queue p; - - if (qempty(q)){ - fprintf( stderr, "removing first element from empty queue\n"); - errsignal(RTESYSER); - } - p = q->next; - q->next = q->next->next; - if (p == q) q = NULL; /* removing last element of the queue */ - free(p); - return(q); -} /* end qremove */ - - -queue qdelete(q, e) /* Delete arbitrary element */ -queue q; -qelem e; -{ - queue p, r, s; - - if (qempty(q)) return(q); - r = q; - p = r->next; - while (p->elem != e) - { - if (p == q) return(q); - r = p; - p = p->next; - } - r->next = p->next; - if (r == p) s = NULL; - else - if (p == q) s = r; - else s = q; - free(p); - return(s); -} /* end qdelete */ - - -queue qrotate(q) /* Remove front and insert at rear */ -queue q; -{ - if (qempty(q)){ - fprintf( stderr, "rotating empty queue\n"); - errsignal(RTESYSER); - } - return (q->next); -} /* end qrotate */ - - -void qfree(q) -queue q; -{ - while (!qempty(q)) - { - free(qfront(q)); - q = qremove(q); - } -} /* end qfree */