From d1cfc560073dbe5bfcaa412b4fea16d6831e743e Mon Sep 17 00:00:00 2001 From: giraffedata Date: Wed, 24 Jul 2013 22:18:59 +0000 Subject: cleanup - declare qsort comparison routines as such git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1980 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- converter/other/fiasco/codec/tiling.c | 70 +++++++++++++++----------------- converter/other/pnmtopalm/palm.h | 8 +--- converter/other/pnmtopalm/palmcolormap.c | 8 +++- converter/other/winicontopam.c | 4 ++ 4 files changed, 44 insertions(+), 46 deletions(-) (limited to 'converter/other') diff --git a/converter/other/fiasco/codec/tiling.c b/converter/other/fiasco/codec/tiling.c index 83eb8b29..89fe3111 100644 --- a/converter/other/fiasco/codec/tiling.c +++ b/converter/other/fiasco/codec/tiling.c @@ -29,22 +29,7 @@ #include "wfalib.h" #include "tiling.h" -/***************************************************************************** - prototypes - -*****************************************************************************/ - -static int -cmpdecvar (const void *value1, const void *value2); -static int -cmpincvar (const void *value1, const void *value2); - -/***************************************************************************** - - public code - -*****************************************************************************/ typedef struct var_list { @@ -52,6 +37,38 @@ typedef struct var_list real_t variance; /* variance of tile */ } var_list_t; +#ifndef LITERAL_FN_DEF_MATCH +static qsort_comparison_fn cmpincvar; +#endif + +static int +cmpincvar(const void * const value1, + const void * const value2) { +/*---------------------------------------------------------------------------- + Sorts by increasing variances (quicksort sorting function) +-----------------------------------------------------------------------------*/ + return + ((var_list_t *) value1)->variance - ((var_list_t *) value2)->variance; +} + + + +#ifndef LITERAL_FN_DEF_MATCH +static qsort_comparison_fn cmpdecvar; +#endif + +static int +cmpdecvar(const void * const value1, + const void * const value2) { +/*---------------------------------------------------------------------------- + Sorts by decreasing variances (quicksort sorting function). +-----------------------------------------------------------------------------*/ + return + ((var_list_t *) value2)->variance - ((var_list_t *) value1)->variance; +} + + + tiling_t * alloc_tiling (fiasco_tiling_e method, unsigned tiling_exponent, unsigned image_level) @@ -214,26 +231,3 @@ perform_tiling (const image_t *image, tiling_t *tiling) } } -/***************************************************************************** - - private code - -*****************************************************************************/ - -static int -cmpincvar (const void *value1, const void *value2) -/* - * Sorts by increasing variances (quicksort sorting function). - */ -{ - return ((var_list_t *) value1)->variance - ((var_list_t *) value2)->variance; -} - -static int -cmpdecvar (const void *value1, const void *value2) -/* - * Sorts by decreasing variances (quicksort sorting function). - */ -{ - return ((var_list_t *) value2)->variance - ((var_list_t *) value1)->variance; -} diff --git a/converter/other/pnmtopalm/palm.h b/converter/other/pnmtopalm/palm.h index 170c8cec..718a66cf 100644 --- a/converter/other/pnmtopalm/palm.h +++ b/converter/other/pnmtopalm/palm.h @@ -44,13 +44,9 @@ typedef struct { typedef Colormap_s * Colormap; -int -palmcolor_compare_indices(const void * const p1, - const void * const p2); +qsort_comparison_fn palmcolor_compare_indices; -int -palmcolor_compare_colors(const void * const p1, - const void * const p2); +qsort_comparison_fn palmcolor_compare_colors; Colormap palmcolor_build_custom_8bit_colormap(unsigned int const rows, diff --git a/converter/other/pnmtopalm/palmcolormap.c b/converter/other/pnmtopalm/palmcolormap.c index a1a1cec1..0f47558c 100644 --- a/converter/other/pnmtopalm/palmcolormap.c +++ b/converter/other/pnmtopalm/palmcolormap.c @@ -10,7 +10,9 @@ int palmcolor_compare_indices(const void * const p1, const void * const p2) { - +/*---------------------------------------------------------------------------- + This is a 'qsort' collation function. +-----------------------------------------------------------------------------*/ if ((*((Color) p1) & 0xFF000000) < (*((Color) p2) & 0xFF000000)) return -1; else if ((*((Color) p1) & 0xFF000000) > (*((Color) p2) & 0xFF000000)) @@ -24,7 +26,9 @@ palmcolor_compare_indices(const void * const p1, int palmcolor_compare_colors(const void * const p1, const void * const p2) { - +/*---------------------------------------------------------------------------- + This is a 'qsort' collation function. +-----------------------------------------------------------------------------*/ unsigned long const val1 = *((const unsigned long *) p1) & 0xFFFFFF; unsigned long const val2 = *((const unsigned long *) p2) & 0xFFFFFF; diff --git a/converter/other/winicontopam.c b/converter/other/winicontopam.c index 9bee8b3c..f41a8db3 100644 --- a/converter/other/winicontopam.c +++ b/converter/other/winicontopam.c @@ -182,6 +182,10 @@ u32_xx(const unsigned char * const buf, +#ifndef LITERAL_FN_DEF_MATCH +static qsort_comparison_fn cmpfn; +#endif + static int cmpfn(const void * const aP, const void * const bP) { -- cgit 1.4.1