From: Nikos Mavrogiannopoulos Date: Sun, 17 Dec 2000 01:34:37 +0000 (+0000) Subject: qsort seems to work now X-Git-Tag: gnutls0-0-6~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7b239638e8122799581ab736438e09c19026052a;p=thirdparty%2Fgnutls.git qsort seems to work now --- diff --git a/lib/gnutls_algorithms.c b/lib/gnutls_algorithms.c index d65d0d9ea6..ef4eacb44f 100644 --- a/lib/gnutls_algorithms.c +++ b/lib/gnutls_algorithms.c @@ -723,7 +723,7 @@ int _gnutls_cipher_suite_count() #define SWAP(x, y) memcpy(tmp,x,size); \ memcpy(x,y,size); \ - memcpy(y,tmp,size) + memcpy(y,tmp,size); #define MAX_ELEM_SIZE 4 inline @@ -742,11 +742,12 @@ inline i = pivot = 0; j = full = (nmemb - 1) * size; - memcpy(ptmp, &base[pivot], size); /* set pivot item */ + memcpy(ptmp, &base[0], size); /* set pivot item */ while (i < j) { - while ((compar(state, &base[i], ptmp) <= 0) && (i < full)) + while ((compar(state, &base[i], ptmp) <= 0) && (i < full)) { i += size; + } while ((compar(state, &base[j], ptmp) >= 0) && (j > 0)) j -= size; @@ -759,7 +760,6 @@ inline SWAP(&base[pivot], &base[j]); pivot = j; } else if (i < pivot) { - fprintf(stderr, "HERE!"); SWAP(&base[pivot], &base[i]); pivot = i; } @@ -784,11 +784,8 @@ _gnutls_qsort(GNUTLS_STATE state, void *_base, size_t nmemb, size_t size, if (snmemb <= 1) return; pivot = _gnutls_partition(state, _base, nmemb, size, compar); -#ifdef SORT_DEBUG - fprintf(stderr, "pivot: %d\n", pivot); -#endif - _gnutls_qsort(state, base, pivot+1, size, compar); + _gnutls_qsort(state, base, pivot