about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2018-01-20 02:55:10 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2018-01-20 02:55:10 +0000
commit02cde1f10196b08b9186467400b1b00397cc5020 (patch)
tree22b6c39a25f64eb59c7aca714ebf5f55f08bee26
parent31f2094321635a5c9c1be0a87ab9a0a70b3d82e9 (diff)
downloadnetpbm-mirror-02cde1f10196b08b9186467400b1b00397cc5020.tar.gz
netpbm-mirror-02cde1f10196b08b9186467400b1b00397cc5020.tar.xz
netpbm-mirror-02cde1f10196b08b9186467400b1b00397cc5020.zip
cleanup
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@3122 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--converter/other/pamtogif.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/converter/other/pamtogif.c b/converter/other/pamtogif.c
index 6c50e42c..8d432da1 100644
--- a/converter/other/pamtogif.c
+++ b/converter/other/pamtogif.c
@@ -742,10 +742,6 @@ codeBuffer_output(CodeBuffer * const codeBufferP,
 
    The code is represented as N bits in the file -- the lower
    N bits of 'code'.  N is a the current code size of *codeBufferP.
-
-   Id 'code' is the maximum possible code for the current code size
-   for *codeBufferP, increase that code size (unless it's already
-   maxed out).
 -----------------------------------------------------------------------------*/
     assert (code <= codeBufferP->maxCode);
 
@@ -1142,30 +1138,33 @@ lookupInHash(LzwCompressor *  const lzwP,
              StringCode *     const codeP,
              unsigned int *   const hashP) {
 
-    int disp;
+    unsigned int disp;
         /* secondary hash stride (after G. Knott) */
-    int i;
+    unsigned int hash;
         /* Index into hash table */
 
-    i = primaryHash(lzwP->stringSoFar, gifPixel, lzwP->hshift);
-    disp = (i == 0) ? 1 : lzwP->hsize - i;
-
-    while (lzwP->hashTable[i].present &&
-           (lzwP->hashTable[i].baseString != lzwP->stringSoFar ||
-            lzwP->hashTable[i].additionalPixel != gifPixel)) {
-        i -= disp;
-        if (i < 0)
-            i += lzwP->hsize;
+    hash = primaryHash(lzwP->stringSoFar, gifPixel, lzwP->hshift);
+    assert(hash < lzwP->hsize);
+    disp = (hash == 0) ? 1 : lzwP->hsize - hash;
+
+    while (lzwP->hashTable[hash].present &&
+           (lzwP->hashTable[hash].baseString != lzwP->stringSoFar ||
+            lzwP->hashTable[hash].additionalPixel != gifPixel)) {
+        if (hash < disp)
+            hash += lzwP->hsize;
+        assert(hash >= disp);
+        hash -= disp;
+        assert(hash < lzwP->hsize);
     }
 
-    if (lzwP->hashTable[i].present) {
+    if (lzwP->hashTable[hash].present) {
         /* Found fcode in hash table */
         *foundP = true;
-        *codeP = lzwP->hashTable[i].combinedString;
+        *codeP  = lzwP->hashTable[hash].combinedString;
     } else {
         /* Found where it _should_ be (but it's not) with primary hash */
         *foundP = false;
-        *hashP = i;
+        *hashP  = hash;
     }
 }