X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/c7b463c9c17665403d001fc59cb649551e93d950..70452c4e85fdaf926e355031f83ef66273551e74:/include/xbt/dynar.h diff --git a/include/xbt/dynar.h b/include/xbt/dynar.h index d2117851ab..4f89ad162f 100644 --- a/include/xbt/dynar.h +++ b/include/xbt/dynar.h @@ -224,16 +224,13 @@ typedef struct xbt_dynar_s { unsigned long elmsize; void *data; void_f_pvoid_t free_f; - xbt_mutex_t mutex; } s_xbt_dynar_t; static XBT_INLINE void -_xbt_dynar_cursor_first(const xbt_dynar_t dynar, +_xbt_dynar_cursor_first(const xbt_dynar_t dynar _XBT_GNUC_UNUSED, unsigned int *const cursor) { - /* don't test for dynar!=NULL. The segfault would tell us */ - if (dynar->mutex) /* ie _dynar_lock(dynar) but not public */ - xbt_mutex_acquire(dynar->mutex); + /* iterating over a NULL dynar is a no-op (but we don't want to have uninitialized counters) */ //XBT_DEBUG("Set cursor on %p to the first position", (void *) dynar); *cursor = 0; @@ -243,11 +240,11 @@ static XBT_INLINE int _xbt_dynar_cursor_get(const xbt_dynar_t dynar, unsigned int idx, void *const dst) { + if (!dynar) /* iterating over a NULL dynar is a no-op */ + return FALSE; if (idx >= dynar->used) { //XBT_DEBUG("Cursor on %p already on last elem", (void *) dynar); - if (dynar->mutex) /* unlock */ - xbt_mutex_release(dynar->mutex); return FALSE; } // XBT_DEBUG("Cash out cursor on %p at %u", (void *) dynar, *idx);