about summary refs log tree commit diff
path: root/lib/libppmd.c
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2010-01-11 09:06:39 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2010-01-11 09:06:39 +0000
commitee59bf32527043077705a8438224cf606671d8f6 (patch)
tree718977a3c3aa2ead010bc31943250182a4b1483a /lib/libppmd.c
parent023cb0a7063d3ff247fb0775f48475bf8321cba4 (diff)
downloadnetpbm-mirror-ee59bf32527043077705a8438224cf606671d8f6.tar.gz
netpbm-mirror-ee59bf32527043077705a8438224cf606671d8f6.tar.xz
netpbm-mirror-ee59bf32527043077705a8438224cf606671d8f6.zip
cleanup
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1095 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'lib/libppmd.c')
-rw-r--r--lib/libppmd.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/lib/libppmd.c b/lib/libppmd.c
index 3b4c9e7c..1234d89f 100644
--- a/lib/libppmd.c
+++ b/lib/libppmd.c
@@ -968,6 +968,7 @@ typedef struct
 
 typedef struct fillobj {
     int n;
+        /* Number of elements in 'coords' */
     int size;
     int curedge;
     int segstart;
@@ -1029,6 +1030,20 @@ ppmd_fill_destroy(struct fillobj * fillObjP) {
 
 
 
+static void
+addCoord(fillobj *  const fhP,
+         ppmd_point const point) {
+
+    coord * const cp = &fhP->coords[fhP->n];
+
+    cp->point = point;
+    cp->edge  = fhP->curedge;
+
+    ++fhP->n;
+}
+
+
+
 void
 ppmd_fill_drawprocp(pixel **     const pixels, 
                     unsigned int const cols, 
@@ -1038,7 +1053,6 @@ ppmd_fill_drawprocp(pixel **     const pixels,
                     const void * const clientdata) {
 
     fillobj * fh;
-    coord * cp;
     coord * ocp;
 
     fh = (fillobj*) clientdata;
@@ -1067,10 +1081,9 @@ ppmd_fill_drawprocp(pixel **     const pixels,
         fh->ydir = 0;
         fh->startydir = 0;
     } else {
-        int dx, dy;
+        int const dx = p.x - ocp->point.x;
+        int const dy = p.y - ocp->point.y;
 
-        dx = p.x - ocp->point.x;
-        dy = p.y - ocp->point.y;
         if (dx < -1 || dx > 1 || dy < -1 || dy > 1) {
             /* Segment break.  Close off old one. */
             if (fh->startydir != 0 && fh->ydir != 0)
@@ -1078,7 +1091,7 @@ ppmd_fill_drawprocp(pixel **     const pixels,
                     /* Oops, first edge and last edge are the same.
                        Renumber the first edge in the old segment.
                     */
-                    const coord * const fcpLast= &(fh->coords[fh->n -1]); 
+                    const coord * const fcpLast= &(fh->coords[fh->n - 1]); 
                     coord * fcp;
 
                     int oldedge;
@@ -1101,10 +1114,7 @@ ppmd_fill_drawprocp(pixel **     const pixels,
                        position but new edge number.
                     */
                     ++fh->curedge;
-                    cp = &fh->coords[fh->n];
-                    cp->point = ocp->point;
-                    cp->edge = fh->curedge;
-                    ++fh->n;
+                    addCoord(fh, ocp->point);
                 }
                 fh->ydir = dy;
                 if (fh->startydir == 0)
@@ -1112,12 +1122,7 @@ ppmd_fill_drawprocp(pixel **     const pixels,
             }
         }
     }
-
-    /* Save this coord. */
-    cp = &fh->coords[fh->n];
-    cp->point = p;
-    cp->edge = fh->curedge;
-    ++fh->n;
+    addCoord(fh, p);
 }