diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2013-07-24 22:18:59 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2013-07-24 22:18:59 +0000 |
commit | d1cfc560073dbe5bfcaa412b4fea16d6831e743e (patch) | |
tree | 0e16bde705966132ed40a77001e1c95414f84306 /editor | |
parent | 6516daea481dab323982d3a2b2aa8baf6988829a (diff) | |
download | netpbm-mirror-d1cfc560073dbe5bfcaa412b4fea16d6831e743e.tar.gz netpbm-mirror-d1cfc560073dbe5bfcaa412b4fea16d6831e743e.tar.xz netpbm-mirror-d1cfc560073dbe5bfcaa412b4fea16d6831e743e.zip |
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
Diffstat (limited to 'editor')
-rw-r--r-- | editor/pamsistoaglyph.c | 17 | ||||
-rw-r--r-- | editor/ppmdist.c | 27 |
2 files changed, 33 insertions, 11 deletions
diff --git a/editor/pamsistoaglyph.c b/editor/pamsistoaglyph.c index 9866b7bd..6b093520 100644 --- a/editor/pamsistoaglyph.c +++ b/editor/pamsistoaglyph.c @@ -247,12 +247,19 @@ findRegionEyeSeparation( gray ** const grayArray, +#ifndef LITERAL_FN_DEF_MATCH +static qsort_comparison_fn compareInts; +#endif + static int -compare_ints( const void * const firstP, - const void * const secondP ) { +compareInts(const void * const a, + const void * const b) { + + const int * const firstP = a; + const int * const secondP = b; - int const first = *(int *)firstP; - int const second = *(int *)secondP; + int const first = *firstP; + int const second = *secondP; int retval; @@ -311,7 +318,7 @@ findEyeSeparation( struct pam * const pamP, rowSeparation[numValidRows++] = sep; } if (numValidRows > 0) { - qsort( rowSeparation, numValidRows, sizeof(int), compare_ints ); + qsort(rowSeparation, numValidRows, sizeof(int), compareInts); bestSeparation = rowSeparation[numValidRows/2]; } free( rowSeparation ); diff --git a/editor/ppmdist.c b/editor/ppmdist.c index bca96adc..e8f17bff 100644 --- a/editor/ppmdist.c +++ b/editor/ppmdist.c @@ -22,6 +22,7 @@ struct colorToGrayEntry { #define MAXCOLORS 255 + static gray newGrayValue(pixel *pix, struct colorToGrayEntry *colorToGrayMap, int colors) { @@ -40,20 +41,34 @@ newGrayValue(pixel *pix, struct colorToGrayEntry *colorToGrayMap, int colors) { +#ifndef LITERAL_FN_DEF_MATCH +static qsort_comparison_fn cmpColorToGrayEntryByIntensity; +#endif + static int -cmpColorToGrayEntryByIntensity(const void *entry1, const void *entry2) { +cmpColorToGrayEntryByIntensity(const void * const a, + const void * const b) { + + const struct colorToGrayEntry * const entry1P = a; + const struct colorToGrayEntry * const entry2P = b; - return ((struct colorToGrayEntry *) entry1)->gray - - ((struct colorToGrayEntry *) entry2)->gray; + return entry1P->gray - entry2P->gray; } +#ifndef LITERAL_FN_DEF_MATCH +static qsort_comparison_fn cmpColorToGrayEntryByFrequency; +#endif + static int -cmpColorToGrayEntryByFrequency(const void * entry1, const void * entry2) { +cmpColorToGrayEntryByFrequency(const void * const a, + const void * const b) { + + const struct colorToGrayEntry * const entry1P = a; + const struct colorToGrayEntry * const entry2P = b; - return ((struct colorToGrayEntry *) entry1)->frequency - - ((struct colorToGrayEntry *) entry2)->frequency; + return entry1P->frequency - entry2P->frequency; } |