From f97b54347110f6bf9a8783bea179dbf35e07ebe9 Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Mon, 4 Sep 2000 20:19:07 +0000 Subject: [PATCH] Rewrote quicksort to solve infinite recursions Win98 explorer.exe. --- dlls/comctl32/comctl32undoc.c | 39 +++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/dlls/comctl32/comctl32undoc.c b/dlls/comctl32/comctl32undoc.c index 9600cd5cee2..670339e71a4 100644 --- a/dlls/comctl32/comctl32undoc.c +++ b/dlls/comctl32/comctl32undoc.c @@ -1614,26 +1614,35 @@ static VOID DPA_QuickSort (LPVOID *lpPtrs, INT l, INT r, PFNDPACOMPARE pfnCompare, LPARAM lParam) { - LPVOID t, v; - INT i, j; + INT m; + LPVOID t; TRACE("l=%i r=%i\n", l, r); - i = l; - j = r; - v = lpPtrs[(int)(l+r)/2]; - do { - while ((pfnCompare)(lpPtrs[i], v, lParam) < 0) i++; - while ((pfnCompare)(lpPtrs[j], v, lParam) > 0) j--; - if (i <= j) + if (l==r) /* one element is always sorted */ + return; + if (r0) + { + t = lpPtrs[m+1]; + memmove(&lpPtrs[l+1],&lpPtrs[l],m-l+1); + lpPtrs[l] = t; + + m++; + } + l++; + } }