summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
5119d31)
believe it ? :)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@1674
48e7efb5-ca39-0410-a469-
dd3cf9ba447f
*/
void xbt_fifo_push_item(xbt_fifo_t l, xbt_fifo_item_t new)
{
*/
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;
(l->count)++;
if (l->head == NULL) {
l->head = new;
return NULL;
item = l->tail;
return NULL;
item = l->tail;
l->tail = item->prev;
if (l->tail == NULL)
l->head = NULL;
l->tail = item->prev;
if (l->tail == NULL)
l->head = NULL;
l->tail->next = NULL;
(l->count)--;
l->tail->next = NULL;
(l->count)--;
*/
void xbt_fifo_unshift_item(xbt_fifo_t l, xbt_fifo_item_t new)
{
*/
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->count)++;
if (l->head == NULL) {
l->head = new;
l->head->prev = NULL;
(l->count)--;
l->head->prev = NULL;
(l->count)--;
* \param l a list
* \param current a bucket
*
* \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 */
*/
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;
+ 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;