diff --git a/dlls/ntdll/misc.c b/dlls/ntdll/misc.c index f4cef42154a..d09ceef2342 100644 --- a/dlls/ntdll/misc.c +++ b/dlls/ntdll/misc.c @@ -2,6 +2,7 @@ * Helper functions for ntdll * * Copyright 2000 Juergen Schmied + * Copyright 2010 Marcus Meissner * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -250,3 +251,45 @@ double CDECL NTDLL_tan( double d ) { return tan( d ); } + + +/* Merge Sort. Algorithm taken from http://www.linux-related.de/index.html?/coding/sort/sort_merge.htm */ +static void mergesort( void *arr, void *barr, int elemsize, int(__cdecl *compar)(const void *, const void *), + int left, int right ) +{ + if(right>left) { + int i, j, k, m; + m=(right+left)/2; + mergesort( arr, barr, elemsize, compar, left, m); + mergesort( arr, barr, elemsize, compar, m+1, right); + +#define X(a,i) ((char*)a+elemsize*(i)) + for (i=m+1; i>left; i--) + memcpy (X(barr,(i-1)),X(arr,(i-1)),elemsize); + for (j=m; j