From 2cf3bf3e88bdb430b0f9e69b5c1ee25a080ae812 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Mon, 9 Jun 2008 02:01:49 +0000 Subject: cleanup git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@646 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- converter/other/pamtouil.c | 56 +++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 31 deletions(-) (limited to 'converter/other/pamtouil.c') diff --git a/converter/other/pamtouil.c b/converter/other/pamtouil.c index 8a80c901..3e67da7d 100644 --- a/converter/other/pamtouil.c +++ b/converter/other/pamtouil.c @@ -34,18 +34,18 @@ struct cmdlineInfo { /* All the information the user supplied in the command line, in a form easy for the program to use. */ - const char *inputFilespec; /* Filespecs of input files */ - char *outname; /* output filename, less "_icon" */ + const char * inputFilespec; /* Filespecs of input files */ + char * outname; /* output filename, less "_icon" */ unsigned int verbose; }; typedef struct { /* character-pixel mapping */ - const char* cixel; /* character string printed for pixel */ - const char* rgbname; /* ascii rgb color, either mnemonic or #rgb value */ - const char* uilname; /* same, with spaces replaced by underbars */ - bool transparent; + const char * cixel; /* character string printed for pixel */ + const char * rgbname; /* ascii rgb color, either mnemonic or #rgb value */ + const char * uilname; /* same, with spaces replaced by underbars */ + bool transparent; } cixel_map; @@ -154,7 +154,8 @@ genNumstr(int const number, static const char * -uilName(const char * const rgbname, bool const transparent) { +uilName(const char * const rgbname, + bool const transparent) { /*---------------------------------------------------------------------------- Return a string in newly malloc'ed storage which is an appropriate color name for the UIL palette. It is the same as the rgb name, @@ -200,8 +201,8 @@ genCmap(struct pam * const pamP, unsigned int colorIndex; { /* Figure out how many characters per pixel we'll be using. - ** Don't want to be forced to link with libm.a, so using a - ** division loop rather than a log function. + Don't want to be forced to link with libm.a, so using a + division loop rather than a log function. */ unsigned int i; for (*charsppP = 0, i = ncolors; i > 0; ++(*charsppP)) @@ -209,7 +210,7 @@ genCmap(struct pam * const pamP, } /* Generate the character-pixel string and the rgb name for each colormap - ** entry. + entry. */ for (colorIndex = 0; colorIndex < ncolors; ++colorIndex) { bool nameAlreadyInCmap; @@ -247,12 +248,12 @@ genCmap(struct pam * const pamP, /* Make the entry a cross-reference to the earlier entry */ cmap[colorIndex].uilname = NULL; cmap[colorIndex].rgbname = NULL; - cmap[colorIndex].cixel = cmap[indexOfName].cixel; + cmap[colorIndex].cixel = cmap[indexOfName].cixel; } else { cmap[colorIndex].uilname = uilName(colorname, transparent); cmap[colorIndex].rgbname = strdup(colorname); if (cmap[colorIndex].rgbname == NULL) - pm_error( "out of memory allocating color name" ); + pm_error("out of memory allocating color name"); cmap[colorIndex].transparent = transparent; @@ -329,15 +330,16 @@ writeRaster(struct pam * const pamP, unsigned int const ncolors, tuplehash const cht, unsigned int const charspp) { - - int row; - /* Write out the ascii character-pixel image. */ +/*---------------------------------------------------------------------------- + Write out the ascii character-pixel image. +-----------------------------------------------------------------------------*/ + unsigned int row; printf("\n"); printf("%s_icon : exported icon( color_table = %s_rgb,\n", outname, outname); for (row = 0; row < pamP->height; ++row) { - int col; + unsigned int col; printf(" '"); for (col = 0; col < pamP->width; ++col) { @@ -360,27 +362,19 @@ writeRaster(struct pam * const pamP, } -static void -freeString(const char * const s) { -/*---------------------------------------------------------------------------- - This is just free(), but with type checking for const char *. ------------------------------------------------------------------------------*/ - free((void *)s); -} - - static void -freeCmap(cixel_map cmap[], unsigned int const ncolors) { +freeCmap(cixel_map const cmap[], + unsigned int const ncolors) { - int i; + unsigned int i; for (i = 0; i < ncolors; ++i) { cixel_map const cmapEntry = cmap[i]; if (cmapEntry.uilname) - freeString(cmapEntry.uilname); + strfree(cmapEntry.uilname); if (cmapEntry.rgbname) - freeString(cmapEntry.rgbname); + strfree(cmapEntry.rgbname); } } @@ -391,8 +385,8 @@ main(int argc, char *argv[]) { struct cmdlineInfo cmdline; struct pam pam; /* Input PAM image */ - FILE* ifP; - tuple** tuples; + FILE * ifP; + tuple ** tuples; unsigned int ncolors; tuplehash cht; tupletable chv; -- cgit 1.4.1