Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Page-level sparse snapshot: work-in-progress, working page_store
[simgrid.git] / src / xbt / dynar.c
index d9e20b9..26c9196 100644 (file)
@@ -1,6 +1,6 @@
 /* a generic DYNamic ARray implementation.                                  */
 
-/* Copyright (c) 2004-2013. The SimGrid Team.
+/* Copyright (c) 2004-2014. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -82,17 +82,6 @@ _xbt_dynar_get_elm(void *const dst,
   memcpy(dst, elm, dynar->elmsize);
 }
 
-static XBT_INLINE
-    void
-_xbt_dynar_put_elm(const xbt_dynar_t dynar,
-                   const unsigned long idx, const void *const src)
-{
-  void *const elm = _xbt_dynar_elm(dynar, idx);
-  const unsigned long elmsize = dynar->elmsize;
-
-  memcpy(elm, src, elmsize);
-}
-
 void xbt_dynar_dump(xbt_dynar_t dynar)
 {
   XBT_INFO("Dynar dump: size=%lu; used=%lu; elmsize=%lu; data=%p; free_f=%p",
@@ -638,11 +627,7 @@ XBT_INLINE void xbt_dynar_cursor_rm(xbt_dynar_t dynar,
 XBT_INLINE void xbt_dynar_sort(xbt_dynar_t dynar,
                                int_f_cpvoid_cpvoid_t compar_fn)
 {
-#ifdef HAVE_MERGESORT
-  mergesort(dynar->data, dynar->used, dynar->elmsize, compar_fn);
-#else
   qsort(dynar->data, dynar->used, dynar->elmsize, compar_fn);
-#endif
 }
 
 /** @brief Sorts a dynar according to their color assuming elements can have only three colors.
@@ -691,10 +676,13 @@ XBT_PUBLIC(void) xbt_dynar_three_way_partition(xbt_dynar_t const dynar,
 }
 
 /** @brief Transform a dynar into a NULL terminated array. 
- *  The dynar won't be usable afterwards.
- * \param dynar the dynar to transform
+ *
+ *  \param dynar the dynar to transform
+ *  \return pointer to the first element of the array
+ *
+ *  Note: The dynar won't be usable afterwards.
  */
-XBT_INLINE void * xbt_dynar_to_array (xbt_dynar_t dynar)
+XBT_INLINE void *xbt_dynar_to_array(xbt_dynar_t dynar)
 {
   void *res;
   xbt_dynar_shrink(dynar, 1);
@@ -704,8 +692,17 @@ XBT_INLINE void * xbt_dynar_to_array (xbt_dynar_t dynar)
   return res;
 }
 
-/*
- * Return 0 if d1 and d2 are equal and 1 if not equal
+/** @brief Compare two dynars
+ *
+ *  \param d1 first dynar to compare
+ *  \param d2 second dynar to compare
+ *  \param compar function to use to compare elements
+ *  \return 0 if d1 and d2 are equal and 1 if not equal
+ *
+ *  d1 and d2 should be dynars of pointers. The compar function takes two
+ *  elements and returns 0 when they are considered equal, and a value different
+ *  of zero when they are considered different. Finally, d2 is destroyed
+ *  afterwards.
  */
 int xbt_dynar_compare(xbt_dynar_t d1, xbt_dynar_t d2,
           int(*compar)(const void *, const void *))