Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a new function xbt_dynar_to_array that transforms a dynar into a
authorsuter <suter@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 2 Dec 2010 13:35:59 +0000 (13:35 +0000)
committersuter <suter@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 2 Dec 2010 13:35:59 +0000 (13:35 +0000)
NULL-terminated array. This may solve backward compatibility issues
due to the change to return type of SD_Simulate. See also:
http://lists.gforge.inria.fr/pipermail/simgrid-user/2010-December/002206.html

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8882 48e7efb5-ca39-0410-a469-dd3cf9ba447f

ChangeLog
include/xbt/dynar.h
src/xbt/dynar.c

index 82f0277..bd7d97a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,12 @@ SimGrid (3.6) unstable; urgency=low
  Simix
  * completely rewrote this module to allow parallel execution.
 
  Simix
  * completely rewrote this module to allow parallel execution.
 
+ XBT
+ * Add a new function xbt_dynar_to_array that transforms a dynar into a
+   NULL-terminated array. This may solve backward compatibility issues
+   due to the change to return type of SD_Simulate. See also:
+   http://lists.gforge.inria.fr/pipermail/simgrid-user/2010-December/002206.html
+
  -- Da SimGrid team <simgrid-devel@lists.gforge.inria.fr>
 
 SimGrid (3.5) stable; urgency=medium
  -- Da SimGrid team <simgrid-devel@lists.gforge.inria.fr>
 
 SimGrid (3.5) stable; urgency=medium
index b38a3e6..563cf2a 100644 (file)
@@ -108,6 +108,7 @@ XBT_PUBLIC(void) xbt_dynar_sort(xbt_dynar_t const dynar,
                                 int_f_cpvoid_cpvoid_t compar_fn);
 XBT_INLINE XBT_PUBLIC(int) xbt_dynar_compare(xbt_dynar_t d1, xbt_dynar_t d2,
                                        int(*compar)(const void *, const void *));
                                 int_f_cpvoid_cpvoid_t compar_fn);
 XBT_INLINE XBT_PUBLIC(int) xbt_dynar_compare(xbt_dynar_t d1, xbt_dynar_t d2,
                                        int(*compar)(const void *, const void *));
+XBT_INLINE void * xbt_dynar_to_array (xbt_dynar_t dynar);
 
 /** @} */
 /** @defgroup XBT_dynar_perl Perl-like use of dynars
 
 /** @} */
 /** @defgroup XBT_dynar_perl Perl-like use of dynars
index 1065cc5..c84b2ee 100644 (file)
@@ -748,6 +748,19 @@ XBT_INLINE void xbt_dynar_sort(xbt_dynar_t dynar,
   _dynar_unlock(dynar);
 }
 
   _dynar_unlock(dynar);
 }
 
+/** @brief Transform a dynar into a NULL terminated array
+ *
+ * \param dynar the dynar to transform
+ */
+XBT_INLINE void * xbt_dynar_to_array (xbt_dynar_t dynar)
+{
+       void * last = xbt_new0(char,dynar->elmsize);
+       xbt_dynar_push(dynar, last);
+       free(last);
+       dynar->used--;
+       return dynar->data;
+}
+
 /*
  * Return 0 if d1 and d2 are equal and 1 if not equal
  */
 /*
  * Return 0 if d1 and d2 are equal and 1 if not equal
  */