From 1b8b7ec966d302f6a49ec6fc84c5afca7901dfcd Mon Sep 17 00:00:00 2001 From: alegrand Date: Fri, 26 Aug 2005 05:58:41 +0000 Subject: [PATCH] Deprecating stupidly named functions... * xbt_fifo_newitem: Use xbt_fifo_new_item instead. * xbt_fifo_freeitem: Use xbt_fifo_free_item instead. * xbt_fifo_getFirstItem: Use xbt_fifo_get_first_item instead. * xbt_fifo_getNextItem: Use xbt_fifo_get_next_item instead. * xbt_fifo_getPrevItem: Use xbt_fifo_get_prev_item instead. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@1668 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- include/xbt/fifo.h | 26 +++++++++++----- src/msg/gos.c | 6 ++-- src/xbt/fifo.c | 74 ++++++++++++++++++++++++++++++++++++---------- 3 files changed, 81 insertions(+), 25 deletions(-) diff --git a/include/xbt/fifo.h b/include/xbt/fifo.h index a06a7e85e2..2b46a58a6e 100644 --- a/include/xbt/fifo.h +++ b/include/xbt/fifo.h @@ -46,10 +46,10 @@ int xbt_fifo_is_in(xbt_fifo_t, void *); * @{ */ -xbt_fifo_item_t xbt_fifo_newitem(void); +xbt_fifo_item_t xbt_fifo_new_item(void); void xbt_fifo_set_item_content(xbt_fifo_item_t, void *); void *xbt_fifo_get_item_content(xbt_fifo_item_t); -void xbt_fifo_freeitem(xbt_fifo_item_t); +void xbt_fifo_free_item(xbt_fifo_item_t); void xbt_fifo_push_item(xbt_fifo_t, xbt_fifo_item_t); xbt_fifo_item_t xbt_fifo_pop_item(xbt_fifo_t); @@ -59,9 +59,9 @@ xbt_fifo_item_t xbt_fifo_shift_item(xbt_fifo_t); void xbt_fifo_remove(xbt_fifo_t, void *); void xbt_fifo_remove_item(xbt_fifo_t, xbt_fifo_item_t); -xbt_fifo_item_t xbt_fifo_getFirstItem(xbt_fifo_t l); -xbt_fifo_item_t xbt_fifo_getNextItem(xbt_fifo_item_t i); -xbt_fifo_item_t xbt_fifo_getPrevItem(xbt_fifo_item_t i); +xbt_fifo_item_t xbt_fifo_get_first_item(xbt_fifo_t l); +xbt_fifo_item_t xbt_fifo_get_next_item(xbt_fifo_item_t i); +xbt_fifo_item_t xbt_fifo_get_prev_item(xbt_fifo_item_t i); /** * \brief List iterator @@ -74,9 +74,9 @@ xbt_fifo_item_t xbt_fifo_getPrevItem(xbt_fifo_item_t i); * Iterates over the whole list. */ #define xbt_fifo_foreach(f,i,n,type) \ - for(i=xbt_fifo_getFirstItem(f); \ + for(i=xbt_fifo_get_first_item(f); \ ((i)?(n=(type)(xbt_fifo_get_item_content(i))):(NULL)); \ - i=xbt_fifo_getNextItem(i)) + i=xbt_fifo_get_next_item(i)) /** @} */ @@ -88,6 +88,18 @@ void **xbt_fifo_to_array(xbt_fifo_t); xbt_fifo_t xbt_fifo_copy(xbt_fifo_t); /** @} */ +/** @name 5. Deprecated functions: don't use! + * + * @{ + */ +xbt_fifo_item_t xbt_fifo_newitem(void); +void xbt_fifo_freeitem(xbt_fifo_item_t); + +xbt_fifo_item_t xbt_fifo_getFirstItem(xbt_fifo_t l); +xbt_fifo_item_t xbt_fifo_getNextItem(xbt_fifo_item_t i); +xbt_fifo_item_t xbt_fifo_getPrevItem(xbt_fifo_item_t i); +/** @} */ + END_DECL() /** @} */ diff --git a/src/msg/gos.c b/src/msg/gos.c index 8262b62ad5..8a74d0f49b 100644 --- a/src/msg/gos.c +++ b/src/msg/gos.c @@ -168,7 +168,7 @@ int MSG_task_Iprobe(m_channel_t channel) CHECK_HOST(); h = MSG_host_self(); h_simdata = h->simdata; - return(xbt_fifo_getFirstItem(h_simdata->mbox[channel])!=NULL); + return(xbt_fifo_get_first_item(h_simdata->mbox[channel])!=NULL); } /** \ingroup msg_gos_functions @@ -193,7 +193,7 @@ int MSG_task_probe_from(m_channel_t channel) DEBUG2("Probing on channel %d (%s)", channel,h->name); - item = xbt_fifo_getFirstItem(h->simdata->mbox[channel]); + item = xbt_fifo_get_first_item(h->simdata->mbox[channel]); if (!item || !(t = xbt_fifo_get_item_content(item))) return -1; @@ -222,7 +222,7 @@ MSG_error_t MSG_channel_select_from(m_channel_t channel, double max_duration, h_simdata = h->simdata; DEBUG2("Probing on channel %d (%s)", channel,h->name); - while(!(item = xbt_fifo_getFirstItem(h->simdata->mbox[channel]))) { + while(!(item = xbt_fifo_get_first_item(h->simdata->mbox[channel]))) { if(max_duration>0) { if(!first_time) { MSG_RETURN(MSG_OK); diff --git a/src/xbt/fifo.c b/src/xbt/fifo.c index 80922f1a77..3ea147bfaf 100644 --- a/src/xbt/fifo.c +++ b/src/xbt/fifo.c @@ -6,9 +6,10 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "xbt/sysdep.h" +#include "xbt/log.h" #include "fifo_private.h" -/*XBT_LOG_NEW_DEFAULT_SUBCATEGORY(fifo,xbt,"FIFO"); UNUSED SO FAR */ +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(fifo,xbt,"FIFO"); /** Constructor * \return a new fifo @@ -29,8 +30,8 @@ void xbt_fifo_free(xbt_fifo_t l) { xbt_fifo_item_t b, tmp; - for (b = xbt_fifo_getFirstitem(l); b; - tmp = b, b = b->next, xbt_fifo_freeitem(tmp)); + for (b = xbt_fifo_get_first_item(l); b; + tmp = b, b = b->next, xbt_fifo_free_item(tmp)); free(l); return; } @@ -46,7 +47,7 @@ xbt_fifo_item_t xbt_fifo_push(xbt_fifo_t l, void *t) { xbt_fifo_item_t new; - new = xbt_fifo_newitem(); + new = xbt_fifo_new_item(); new->content = t; xbt_fifo_push_item(l,new); @@ -69,7 +70,7 @@ void *xbt_fifo_pop(xbt_fifo_t l) if(!(item = xbt_fifo_pop_item(l))) return NULL; content = item->content; - xbt_fifo_freeitem(item); + xbt_fifo_free_item(item); return content; } @@ -84,7 +85,7 @@ xbt_fifo_item_t xbt_fifo_unshift(xbt_fifo_t l, void *t) { xbt_fifo_item_t new; - new = xbt_fifo_newitem(); + new = xbt_fifo_new_item(); new->content = t; xbt_fifo_unshift_item(l,new); return new; @@ -106,7 +107,7 @@ void *xbt_fifo_shift(xbt_fifo_t l) if(!(item = xbt_fifo_shift_item(l))) return NULL; content = item->content; - xbt_fifo_freeitem(item); + xbt_fifo_free_item(item); return content; } @@ -217,7 +218,7 @@ void xbt_fifo_remove(xbt_fifo_t l, void *t) continue; /* remove the item */ xbt_fifo_remove_item(l, current); - xbt_fifo_freeitem(current); + xbt_fifo_free_item(current); /* WILL NOT REMOVE DUPLICATES */ break; } @@ -259,7 +260,7 @@ void xbt_fifo_remove_item(xbt_fifo_t l, xbt_fifo_item_t current) */ int xbt_fifo_is_in(xbt_fifo_t f, void *content) { - xbt_fifo_item_t item = xbt_fifo_getFirstitem(f); + xbt_fifo_item_t item = xbt_fifo_get_first_item(f); while (item) { if (item->content == content) return 1; @@ -283,7 +284,7 @@ void **xbt_fifo_to_array(xbt_fifo_t f) else array = xbt_new0(void *, f->count); - for (i = 0, b = xbt_fifo_getFirstitem(f); b; i++, b = b->next) { + for (i = 0, b = xbt_fifo_get_first_item(f); b; i++, b = b->next) { array[i] = b->content; } return array; @@ -300,7 +301,7 @@ xbt_fifo_t xbt_fifo_copy(xbt_fifo_t f) copy = xbt_fifo_new(); - for (b = xbt_fifo_getFirstitem(f); b; b = b->next) { + for (b = xbt_fifo_get_first_item(f); b; b = b->next) { xbt_fifo_push(copy, b->content); } return copy; @@ -309,11 +310,19 @@ xbt_fifo_t xbt_fifo_copy(xbt_fifo_t f) /** Constructor * \return a new bucket */ -xbt_fifo_item_t xbt_fifo_newitem(void) +xbt_fifo_item_t xbt_fifo_new_item(void) { return xbt_new0(struct xbt_fifo_item,1); } +/** \deprecated Use #xbt_fifo_new_item instead. + */ +xbt_fifo_item_t xbt_fifo_newitem(void) +{ + WARN0("This function is deprecated. Use xbt_fifo_new_item."); + return xbt_fifo_new_item(); +} + /** * \param i a bucket * \param v an object @@ -339,8 +348,18 @@ void *xbt_fifo_get_item_content(xbt_fifo_item_t i) * * Free the bucket but does not modifies the object (if any) that was stored in it. */ +void xbt_fifo_free_item(xbt_fifo_item_t b) +{ + free(b); + return; +} + +/** Destructor + * \deprecated Use #xbt_fifo_free_item instead. + */ void xbt_fifo_freeitem(xbt_fifo_item_t b) { + WARN0("This function is deprecated. Use xbt_fifo_free_item."); free(b); return; } @@ -358,30 +377,55 @@ int xbt_fifo_size(xbt_fifo_t f) * \param l a list * \return the head of \a l. */ -xbt_fifo_item_t xbt_fifo_getFirstItem(xbt_fifo_t l) +xbt_fifo_item_t xbt_fifo_get_first_item(xbt_fifo_t l) { return l->head; } +/** \deprecated Use #xbt_fifo_get_first_item instead. + */ +xbt_fifo_item_t xbt_fifo_getFirstItem(xbt_fifo_t l) +{ + WARN0("This function is deprecated. Use xbt_fifo_get_first_item."); + return xbt_fifo_get_first_item(l); +} + /** * \param i a bucket * \return the bucket that comes next */ -xbt_fifo_item_t xbt_fifo_getNextItem(xbt_fifo_item_t i) +xbt_fifo_item_t xbt_fifo_get_next_item(xbt_fifo_item_t i) { if(i) return i->next; return NULL; } +/** \deprecated Use #xbt_fifo_get_next_item instead. + */ +xbt_fifo_item_t xbt_fifo_getNextItem(xbt_fifo_item_t i) +{ + WARN0("This function is deprecated. Use xbt_fifo_get_next_item."); + return xbt_fifo_get_next_item(i); +} + /** * \param i a bucket * \return the bucket that is just before \a i. */ -xbt_fifo_item_t xbt_fifo_getPrevItem(xbt_fifo_item_t i) +xbt_fifo_item_t xbt_fifo_get_prev_item(xbt_fifo_item_t i) { if(i) return i->prev; return NULL; } + +/** \deprecated Use #xbt_fifo_get_prev_item instead. + */ +xbt_fifo_item_t xbt_fifo_getPrevItem(xbt_fifo_item_t i) +{ + WARN0("This function is deprecated. Use xbt_fifo_get_prev_item."); + return xbt_fifo_get_prev_item(i); +} + /* @} */ -- 2.20.1