X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/53f1aab6d0ed79310d4daba0e05a5c61f5cbab4d..f3ac24207e20bfbf5f44be62ab5186a14730a0b3:/src/xbt/fifo.c diff --git a/src/xbt/fifo.c b/src/xbt/fifo.c index f91ab8321f..84a3ade3bb 100644 --- a/src/xbt/fifo.c +++ b/src/xbt/fifo.c @@ -249,6 +249,31 @@ int xbt_fifo_remove(xbt_fifo_t l, void *t) return 0; } + +/** + * \param l + * \param t an objet + * + * removes all occurences of \a t from \a l. + * \return 1 if an item was removed and 0 otherwise. + */ +int xbt_fifo_remove_all(xbt_fifo_t l, void *t) +{ + xbt_fifo_item_t current, current_next; + int res=0; + + for (current = l->head; current; current = current_next) { + current_next = current->next; + if (current->content != t) + continue; + /* remove the item */ + xbt_fifo_remove_item(l, current); + xbt_fifo_free_item(current); + res=1; + } + return res; +} + /** * \param l a list * \param current a bucket @@ -475,6 +500,7 @@ xbt_fifo_item_t xbt_fifo_getPrevItem(xbt_fifo_item_t i) void xbt_fifo_exit(void) { if (item_mallocator != NULL) { xbt_mallocator_free(item_mallocator); + item_mallocator = NULL; } }