about summary refs log tree commit diff
path: root/converter
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2023-09-13 23:05:13 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2023-09-13 23:05:13 +0000
commit868c28a9926bbba535f97066b1570b7e56c6d20f (patch)
tree6f36cd7c19516a1bd37216d85f42df2956406f53 /converter
parent3a6c35a71405962911e7d052f6567ce4ed547bdb (diff)
downloadnetpbm-mirror-868c28a9926bbba535f97066b1570b7e56c6d20f.tar.gz
netpbm-mirror-868c28a9926bbba535f97066b1570b7e56c6d20f.tar.xz
netpbm-mirror-868c28a9926bbba535f97066b1570b7e56c6d20f.zip
cleanup
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4645 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter')
-rw-r--r--converter/pbm/pbmto4425.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/converter/pbm/pbmto4425.c b/converter/pbm/pbmto4425.c
index 0a3dfbbe..f18b2e5a 100644
--- a/converter/pbm/pbmto4425.c
+++ b/converter/pbm/pbmto4425.c
@@ -16,7 +16,7 @@ static unsigned int const vmapHeight = 23;
 
 
 static void
-initMap(unsigned char * const vmap) {
+initMap(char * const vmap) {
 
     unsigned int col;
 
@@ -24,16 +24,16 @@ initMap(unsigned char * const vmap) {
         unsigned int row;
 
         for (row = 0; row < vmapHeight; ++row)
-            vmap[row * vmapWidth + col] = 0x20;
+            vmap[row * vmapWidth + col] = ' ';
     }
 }
 
 
 
 static void
-setVmap(unsigned char * const vmap,
-        unsigned int    const x,
-        unsigned int    const y) {
+setVmap(char *       const vmap,
+        unsigned int const x,
+        unsigned int const y) {
 
     unsigned int const ix = x/2;
     unsigned int const iy = y/3;
@@ -47,8 +47,8 @@ setVmap(unsigned char * const vmap,
 
 
 static void
-fillMap(FILE *          const pbmFileP,
-        unsigned char * const vmap) {
+fillMap(FILE * const pbmFileP,
+        char * const vmap) {
 
     unsigned int const xres = vmapWidth  * 2;
     unsigned int const yres = vmapHeight * 3;
@@ -73,8 +73,8 @@ fillMap(FILE *          const pbmFileP,
 
 
 static void
-printMap(unsigned char * const vmap,
-         FILE *          const ofP) {
+printMap(char * const vmap,
+         FILE * const ofP) {
 
     unsigned int row;
 
@@ -90,7 +90,7 @@ printMap(unsigned char * const vmap,
         unsigned int col;
 
         for (endCol = vmapWidth;
-             endCol > 0 && vmap[row * vmapWidth + (endCol-1)] == 0x20;
+             endCol > 0 && vmap[row * vmapWidth + (endCol-1)] == ' ';
              --endCol)
             ;
 
@@ -108,11 +108,11 @@ printMap(unsigned char * const vmap,
 int
 main(int argc, const char ** argv) {
 
-    int argn;
+    unsigned int argn;
     const char * inputFileNm;
     FILE * ifP;
 
-    unsigned char * vmap;
+    char * vmap;  /* malloced */
 
     pm_proginit(&argc, argv);
 
@@ -133,6 +133,8 @@ main(int argc, const char ** argv) {
 
     ifP = pm_openr(inputFileNm);
 
+    assert(vmapWidth < UINT_MAX/vmapHeight);
+
     MALLOCARRAY(vmap, vmapWidth * vmapHeight);
     if (!vmap)
         pm_error("Cannot allocate memory for %u x %u pixels",
@@ -142,6 +144,8 @@ main(int argc, const char ** argv) {
     fillMap(ifP, vmap);
     printMap(vmap, stdout);
 
+    free(vmap);
+
     /* If the program failed, it previously aborted with nonzero completion
        code, via various function calls.
     */