/* dynar - a generic dynamic array */
-/* Copyright (c) 2004, 2005, 2006, 2007, 2009, 2010. The SimGrid Team.
+/* Copyright (c) 2004-2007, 2009-2015. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
#include <string.h> /* memcpy */
-#include "xbt/misc.h" /* SG_BEGIN_DECL */
+#include "xbt/base.h" /* SG_BEGIN_DECL */
#include "xbt/function_types.h"
SG_BEGIN_DECL()
XBT_PUBLIC(xbt_dynar_t) xbt_dynar_new(const unsigned long elm_size,
void_f_pvoid_t const free_f);
-XBT_PUBLIC(xbt_dynar_t) xbt_dynar_new_sync(const unsigned long elm_size,
- void_f_pvoid_t const free_f);
XBT_PUBLIC(void) xbt_dynar_free(xbt_dynar_t * dynar);
XBT_PUBLIC(void) xbt_dynar_free_voidp(void *dynar);
XBT_PUBLIC(void) xbt_dynar_free_container(xbt_dynar_t * dynar);
* DynArr during the traversal. To remove elements, use the
* xbt_dynar_cursor_rm() function.
*
- * Do not call these functions directly, but only the xbt_dynar_foreach macro.
- *
- * For synchronized dynars, the dynar will be locked during the whole
- * loop and it will get unlocked automatically if you traverse all
- * elements. If you want to break the loop before the end, make sure
- * to call xbt_dynar_cursor_unlock() before the <tt>break;</tt>
+ * Do not call these function directly, but only within the xbt_dynar_foreach
+ * macro.
*
* @{
*/
XBT_PUBLIC(void) xbt_dynar_cursor_rm(xbt_dynar_t dynar,
unsigned int *const cursor);
-XBT_PUBLIC(void) xbt_dynar_cursor_unlock(xbt_dynar_t dynar);
/* do not use this structure internals directly, but use the public interface
* This was made public to allow:
* - sending such beasts over the network
*/
-#include "xbt/synchro_core.h"
typedef struct xbt_dynar_s {
unsigned long size;
unsigned long used;
_xbt_dynar_cursor_get(_dynar,_cursor,&_data) ; \
(_cursor)++ )
+#ifndef __cplusplus
+#define xbt_dynar_foreach_ptr(_dynar,_cursor,_ptr) \
+ for (_xbt_dynar_cursor_first(_dynar,&(_cursor)) ; \
+ (_ptr = _cursor < _dynar->used ? xbt_dynar_get_ptr(_dynar,_cursor) : NULL) ; \
+ (_cursor)++ )
+#else
+#define xbt_dynar_foreach_ptr(_dynar,_cursor,_ptr) \
+ for (_xbt_dynar_cursor_first(_dynar,&(_cursor)) ; \
+ (_ptr = _cursor < _dynar->used ? (decltype(_ptr)) xbt_dynar_get_ptr(_dynar,_cursor) : NULL) ; \
+ (_cursor)++ )
+#endif
/** @} */
SG_END_DECL()