*/
void xbt_fifo_push_item(xbt_fifo_t l, xbt_fifo_item_t new)
{
+ xbt_assert0((new->next == NULL)&&(new->prev == NULL),"Invalid item!");
(l->count)++;
if (l->head == NULL) {
l->head = new;
return NULL;
item = l->tail;
-
+
l->tail = item->prev;
if (l->tail == NULL)
l->head = NULL;
l->tail->next = NULL;
(l->count)--;
+
+ item->prev = NULL;
+
return item;
}
*/
void xbt_fifo_unshift_item(xbt_fifo_t l, xbt_fifo_item_t new)
{
+ xbt_assert0((new->next == NULL)&&(new->prev == NULL),"Invalid item!");
(l->count)++;
if (l->head == NULL) {
l->head = new;
l->head->prev = NULL;
(l->count)--;
+
+ item->next = NULL;
+
return item;
}
* \param l a list
* \param current a bucket
*
- * removes a the bucket \a current from the list \a l
+ * removes a bucket \a current from the list \a l. This function implicitely
+ * assumes (and doesn't check!) that this item belongs to this list...
*/
void xbt_fifo_remove_item(xbt_fifo_t l, xbt_fifo_item_t current)
{
if (l->head == l->tail) { /* special case */
- l->head = NULL;
- l->tail = NULL;
- (l->count)--;
- return;
- }
-
- if (current == l->head) { /* It's the head */
- l->head = current->next;
- l->head->prev = NULL;
- } else if (current == l->tail) { /* It's the tail */
- l->tail = current->prev;
- l->tail->next = NULL;
- } else { /* It's in the middle */
- current->prev->next = current->next;
- current->next->prev = current->prev;
- }
+ xbt_assert0((current==l->head),"This item is not in the list!");
+ l->head = NULL;
+ l->tail = NULL;
(l->count)--;
+ current->prev = current->next = NULL;
+ return;
+ }
+
+ if (current == l->head) { /* It's the head */
+ l->head = current->next;
+ l->head->prev = NULL;
+ } else if (current == l->tail) { /* It's the tail */
+ l->tail = current->prev;
+ l->tail->next = NULL;
+ } else { /* It's in the middle */
+ current->prev->next = current->next;
+ current->next->prev = current->prev;
+ }
+ (l->count)--;
+ current->prev = current->next = NULL;
}
/**