A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Set a fixed seed for srand and srand48
[simgrid.git]
/
include
/
xbt
/
dynar.h
diff --git
a/include/xbt/dynar.h
b/include/xbt/dynar.h
index
87b501c
..
79b590d
100644
(file)
--- 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;
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,
unsigned int *const cursor)
{
} s_xbt_dynar_t;
static XBT_INLINE void
_xbt_dynar_cursor_first(const xbt_dynar_t dynar,
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;
//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)
{
_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 (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);
return FALSE;
}
// XBT_DEBUG("Cash out cursor on %p at %u", (void *) dynar, *idx);
@@
-279,7
+276,7
@@
xbt_dynar_foreach (dyn,cpt,str) {
*/
#define xbt_dynar_foreach(_dynar,_cursor,_data) \
for (_xbt_dynar_cursor_first(_dynar,&(_cursor)) ; \
*/
#define xbt_dynar_foreach(_dynar,_cursor,_data) \
for (_xbt_dynar_cursor_first(_dynar,&(_cursor)) ; \
-
_xbt_dynar_cursor_get(_dynar,_cursor,&_data) ; \
+ _xbt_dynar_cursor_get(_dynar,_cursor,&_data) ; \
(_cursor)++ )
/** @} */
(_cursor)++ )
/** @} */