X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/30f1c8c5e4b8a7b6e593c7bb885ffad766ae6f5d..b3b356352e87ae00a20f737c48e19b0c8413455a:/include/xbt/swag.h diff --git a/include/xbt/swag.h b/include/xbt/swag.h index d6224e409e..8800b4bcb1 100644 --- a/include/xbt/swag.h +++ b/include/xbt/swag.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010. The SimGrid Team. +/* Copyright (c) 2004-2015. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -90,6 +90,13 @@ XBT_PUBLIC(xbt_swag_t) xbt_swag_new(size_t offset); XBT_PUBLIC(void) xbt_swag_free(xbt_swag_t swag); XBT_PUBLIC(void) xbt_swag_init(xbt_swag_t swag, size_t offset); +/** + * \brief Makes a swag empty. + * \param swag a swag + * @hideinitializer + */ +#define xbt_swag_reset(swag) do {} while(xbt_swag_extract(swag)) + /** * \param obj the objet to insert in the swag * \param swag a swag @@ -142,11 +149,17 @@ static XBT_INLINE void *xbt_swag_getFirst(xbt_swag_t swag) * @param swag what to iterate over * @warning you cannot modify the \a swag while using this loop * @hideinitializer */ +#ifndef __cplusplus #define xbt_swag_foreach(obj,swag) \ for((obj)=xbt_swag_getFirst((swag)); \ (obj)!=NULL; \ (obj)=xbt_swag_getNext((obj),(swag)->offset)) - +#else +#define xbt_swag_foreach(obj,swag) \ + for((obj)=(decltype(obj)) xbt_swag_getFirst((swag)); \ + (obj)!=NULL; \ + (obj)=(decltype(obj)) xbt_swag_getNext((obj),(swag)->offset)) +#endif /** * @brief A safe swag iterator * @param obj the indice of the loop @@ -161,7 +174,7 @@ static XBT_INLINE void *xbt_swag_getFirst(xbt_swag_t swag) #define xbt_swag_foreach_safe(obj,obj_next,swag) \ for((obj)=xbt_swag_getFirst((swag)), \ ((obj)?(obj_next=xbt_swag_getNext((obj),(swag)->offset)): \ - (obj_next=NULL)); \ + (obj_next=NULL)); \ (obj)!=NULL; \ (obj)=obj_next, \ ((obj)?(obj_next=xbt_swag_getNext((obj),(swag)->offset)): \