From: alegrand Date: Sat, 4 Aug 2007 21:48:43 +0000 (+0000) Subject: Return whether an item was removed or not when trying to remove a value in a fifo. X-Git-Tag: v3.3~1408 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/53f1aab6d0ed79310d4daba0e05a5c61f5cbab4d Return whether an item was removed or not when trying to remove a value in a fifo. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@3952 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/include/xbt/fifo.h b/include/xbt/fifo.h index dacb28afc3..c63c371ec6 100644 --- a/include/xbt/fifo.h +++ b/include/xbt/fifo.h @@ -65,7 +65,7 @@ XBT_PUBLIC(xbt_fifo_item_t) xbt_fifo_pop_item(xbt_fifo_t); XBT_PUBLIC(void) xbt_fifo_unshift_item(xbt_fifo_t, xbt_fifo_item_t); XBT_PUBLIC(xbt_fifo_item_t) xbt_fifo_shift_item(xbt_fifo_t); -XBT_PUBLIC(void) xbt_fifo_remove(xbt_fifo_t, void *); +XBT_PUBLIC(int) xbt_fifo_remove(xbt_fifo_t, void *); XBT_PUBLIC(void) xbt_fifo_remove_item(xbt_fifo_t, xbt_fifo_item_t); XBT_PUBLIC(xbt_fifo_item_t) xbt_fifo_get_first_item(xbt_fifo_t l); diff --git a/src/xbt/fifo.c b/src/xbt/fifo.c index 09fed3254e..f91ab8321f 100644 --- a/src/xbt/fifo.c +++ b/src/xbt/fifo.c @@ -229,8 +229,9 @@ xbt_fifo_item_t xbt_fifo_shift_item(xbt_fifo_t l) * * removes the first occurence of \a t from \a l. * \warning it will not remove duplicates + * \return 1 if an item was removed and 0 otherwise. */ -void xbt_fifo_remove(xbt_fifo_t l, void *t) +int xbt_fifo_remove(xbt_fifo_t l, void *t) { xbt_fifo_item_t current, current_next; @@ -243,9 +244,9 @@ void xbt_fifo_remove(xbt_fifo_t l, void *t) xbt_fifo_remove_item(l, current); xbt_fifo_free_item(current); /* WILL NOT REMOVE DUPLICATES */ - break; + return 1; } - return; + return 0; } /**