Move remaining C files in utility to C++
[alexxy/gromacs.git] / src / gromacs / utility / qsort_threadsafe.cpp
similarity index 98%
rename from src/gromacs/utility/qsort_threadsafe.c
rename to src/gromacs/utility/qsort_threadsafe.cpp
index 0f0849076d9d86296102516e970934c9d7c2b5d7..6a63bf225f43857a984686b22a2954ead4c47384 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2012,2014, by the GROMACS development team, led by
+ * Copyright (c) 2010,2012,2014,2015, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -131,6 +131,11 @@ gmx_qsort(void *           base,
     int    t, v;
     size_t s, st;
 
+    if (size == 0)
+    {
+        return;
+    }
+
     cbase = (char *)base;
 
     swaptype = (size_t)(cbase - (char *)0) % sizeof(int) || size % sizeof(int) ? 2 : size == sizeof(int) ? 0 : 1;
@@ -175,8 +180,8 @@ gmx_qsort(void *           base,
     }
     else
     {
-        pv = (char*)(void*)&v;
         v  = *(int *)pm;
+        pv = (char*)(void*)&v;
     }
 
     pa = pb = cbase;