From db63e6dbc34a772d9feb2351b81ac122cf52df94 Mon Sep 17 00:00:00 2001 From: Al Date: Sun, 4 Oct 2015 18:23:09 -0400 Subject: [PATCH] [fix] making ksort methods static --- src/klib/ksort.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/klib/ksort.h b/src/klib/ksort.h index 996902a9..a0ea6256 100644 --- a/src/klib/ksort.h +++ b/src/klib/ksort.h @@ -54,7 +54,7 @@ typedef struct { #define KSORT_SWAP(type_t, a, b) { register type_t t=(a); (a)=(b); (b)=t; } #define KSORT_INIT(name, type_t, __sort_lt) \ - void ks_mergesort_##name(size_t n, type_t array[], type_t temp[]) \ + static void ks_mergesort_##name(size_t n, type_t array[], type_t temp[]) \ { \ type_t *a2[2], *a, *b; \ int curr, shift; \ @@ -102,7 +102,7 @@ typedef struct { } \ if (temp == 0) free(a2[1]); \ } \ - void ks_heapadjust_##name(size_t i, size_t n, type_t l[]) \ + static void ks_heapadjust_##name(size_t i, size_t n, type_t l[]) \ { \ size_t k = i; \ type_t tmp = l[i]; \ @@ -113,13 +113,13 @@ typedef struct { } \ l[i] = tmp; \ } \ - void ks_heapmake_##name(size_t lsize, type_t l[]) \ + static void ks_heapmake_##name(size_t lsize, type_t l[]) \ { \ size_t i; \ for (i = (lsize >> 1) - 1; i != (size_t)(-1); --i) \ ks_heapadjust_##name(i, lsize, l); \ } \ - void ks_heapsort_##name(size_t lsize, type_t l[]) \ + static void ks_heapsort_##name(size_t lsize, type_t l[]) \ { \ size_t i; \ for (i = lsize - 1; i > 0; --i) { \ @@ -135,7 +135,7 @@ typedef struct { swap_tmp = *j; *j = *(j-1); *(j-1) = swap_tmp; \ } \ } \ - void ks_combsort_##name(size_t n, type_t a[]) \ + static void ks_combsort_##name(size_t n, type_t a[]) \ { \ const double shrink_factor = 1.2473309501039786540366528676643; \ int do_swap; \ @@ -157,7 +157,7 @@ typedef struct { } while (do_swap || gap > 2); \ if (gap != 1) __ks_insertsort_##name(a, a + n); \ } \ - void ks_introsort_##name(size_t n, type_t a[]) \ + static void ks_introsort_##name(size_t n, type_t a[]) \ { \ int d; \ ks_isort_stack_t *top, *stack; \ @@ -210,7 +210,7 @@ typedef struct { } \ /* This function is adapted from: http://ndevilla.free.fr/median/ */ \ /* 0 <= kk < n */ \ - type_t ks_ksmall_##name(size_t n, type_t arr[], size_t kk) \ + static type_t ks_ksmall_##name(size_t n, type_t arr[], size_t kk) \ { \ type_t *low, *high, *k, *ll, *hh, *mid; \ low = arr; high = arr + n - 1; k = arr + kk; \ @@ -237,7 +237,7 @@ typedef struct { if (hh >= k) high = hh - 1; \ } \ } \ - void ks_shuffle_##name(size_t n, type_t a[]) \ + static void ks_shuffle_##name(size_t n, type_t a[]) \ { \ int i, j; \ for (i = n; i > 1; --i) { \ @@ -246,7 +246,7 @@ typedef struct { tmp = a[j]; a[j] = a[i-1]; a[i-1] = tmp; \ } \ } \ - void ks_sample_##name(size_t n, size_t r, type_t a[]) /* FIXME: NOT TESTED!!! */ \ + static void ks_sample_##name(size_t n, size_t r, type_t a[]) /* FIXME: NOT TESTED!!! */ \ { /* reference: http://code.activestate.com/recipes/272884/ */ \ int i, k, pop = n; \ for (i = (int)r, k = 0; i >= 0; --i) { \