Go to the source code of this file.
Data Structures | |||||
| struct | QUEUE | ||||
| Queue structure. More... | |||||
Typedefs | |||||
| typedef QUEUE | queue_t | ||||
| Queue structure. | |||||
Functions | |||||
| int | count_queue (queue_t **q) | ||||
Get the number of elements presents in the queue.
| |||||
| void | add_queue (queue_t **q, void *v) | ||||
Add an element to a circular queue.
| |||||
| int | rem_queue (queue_t **q, void *v) | ||||
Remove an element from a circular queue.
| |||||
| void * | pick_queue (queue_t **q) | ||||
Get the first element in the queue and update the pointer.
| |||||
| void * | find_queue (queue_t **q, void *v) | ||||
Find an element into a circular queue.
| |||||
Definition in file queue.h.
|
|
Queue structure.
|
|
||||||||||||
|
Add an element to a circular queue.
Definition at line 69 of file queue.c.
00070 {
00071 queue_t *p;
00072
00073 p = (queue_t *)kmalloc(sizeof(queue_t));
00074 if (p == NULL) error("Out of virtual memory!!!");
00075
00076 p->value = v;
00077
00078 if (*q==NULL)
00079 {
00080 p->next = p;
00081 *q=p;
00082 }
00083 else
00084 {
00085 p->next = (*q)->next;
00086 (*q)->next = p;
00087 }
00088 }
|
|
|
Get the number of elements presents in the queue.
Definition at line 25 of file queue.c.
|
|
||||||||||||
|
Find an element into a circular queue.
Definition at line 141 of file queue.c.
00142 {
00143 queue_t *t;
00144
00145 if (q==NULL) return(FALSE);
00146 if (*q==NULL) return(FALSE);
00147
00148 // Search for the element 'v' //
00149 t = *q;
00150 do
00151 {
00152 if (t->value == v)
00153 {
00154 // Element found! //
00155 return( t->value );
00156 }
00157 t = t->next;
00158 } while (t != *q);
00159 // Element not found! //
00160 return( NULL );
00161 }
|
|
|
Get the first element in the queue and update the pointer.
Definition at line 48 of file queue.c.
|
|
||||||||||||
|
Remove an element from a circular queue.
Definition at line 97 of file queue.c.
00098 {
00099 queue_t *t, *t2;
00100
00101 if (q==NULL) return(FALSE);
00102 if (*q==NULL) return(FALSE);
00103
00104 // Search for the element 'v' //
00105 t = *q;
00106 do
00107 {
00108 t2 = t;
00109 t = t->next;
00110
00111 if (t->value == v)
00112 {
00113 // Element found! //
00114 t2->next = t->next;
00115
00116 if (t == *q)
00117 {
00118 // Deleting current element //
00119 if (t == t->next)
00120 *q = NULL;
00121 else
00122 *q = (*q)->next;
00123 };
00124 kfree(t);
00125 return(TRUE);
00126 }
00127 } while (t != *q);
00128 return(FALSE);
00129 }
|
1.2.18