Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove cycles in #include files
[simgrid.git] / include / xbt / dynar.h
index 4cf11cc..5ee6b03 100644 (file)
@@ -1,6 +1,6 @@
 /* dynar - a generic dynamic array                                          */
 
-/* Copyright (c) 2004, 2005, 2006, 2007, 2009, 2010. The SimGrid Team.
+/* Copyright (c) 2004-2007, 2009-2014. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -11,7 +11,7 @@
 
 #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()
@@ -284,6 +284,17 @@ xbt_dynar_foreach (dyn,cpt,str) {
       _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()