]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Replace unsigned short with uint16_t 34/head
authorHans Kristian Rosbach <hk-git@circlestorm.org>
Sat, 16 May 2015 19:23:07 +0000 (21:23 +0200)
committerMika Lindqvist <postmaster@raasu.org>
Fri, 22 May 2015 19:15:29 +0000 (22:15 +0300)
Conflicts:
inflate.h
inftrees.c
inftrees.h
match.c

infback.c
inflate.c
inflate.h
inftrees.c
inftrees.h
match.c
test/infcover.c

index 290e839d6058050bc69e8b2e6b4d95b559e08c2b..08e77fa455f18294dc5da1bd27ebca06442a4173 100644 (file)
--- a/infback.c
+++ b/infback.c
@@ -249,7 +249,7 @@ int ZEXPORT inflateBack(z_stream *strm, in_func in, void *in_desc,
     code last;                  /* parent table entry */
     unsigned len;               /* length to copy for repeats, bits to drop */
     int ret;                    /* return code */
-    static const unsigned short order[19] = /* permutation of code lengths */
+    static const uint16_t order[19] = /* permutation of code lengths */
         {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
 
     /* Check that the strm exists and that the state was initialized */
@@ -360,7 +360,7 @@ int ZEXPORT inflateBack(z_stream *strm, in_func in, void *in_desc,
             state->have = 0;
             while (state->have < state->ncode) {
                 NEEDBITS(3);
-                state->lens[order[state->have++]] = (unsigned short)BITS(3);
+                state->lens[order[state->have++]] = (uint16_t)BITS(3);
                 DROPBITS(3);
             }
             while (state->have < 19)
@@ -422,7 +422,7 @@ int ZEXPORT inflateBack(z_stream *strm, in_func in, void *in_desc,
                         break;
                     }
                     while (copy--)
-                        state->lens[state->have++] = (unsigned short)len;
+                        state->lens[state->have++] = (uint16_t)len;
                 }
             }
 
index a3a342f97073575d51d2c5d8385f7d45b0b543f4..a63f699bbdc3368e7a2c1b7b17e3101831d2efaa 100644 (file)
--- a/inflate.c
+++ b/inflate.c
@@ -593,7 +593,7 @@ int ZEXPORT inflate(z_stream *strm, int flush)
 #ifdef GUNZIP
     unsigned char hbuf[4];      /* buffer for gzip header crc calculation */
 #endif
-    static const unsigned short order[19] = /* permutation of code lengths */
+    static const uint16_t order[19] = /* permutation of code lengths */
         {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
 
     if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL ||
@@ -886,7 +886,7 @@ int ZEXPORT inflate(z_stream *strm, int flush)
         case LENLENS:
             while (state->have < state->ncode) {
                 NEEDBITS(3);
-                state->lens[order[state->have++]] = (unsigned short)BITS(3);
+                state->lens[order[state->have++]] = (uint16_t)BITS(3);
                 DROPBITS(3);
             }
             while (state->have < 19)
@@ -948,7 +948,7 @@ int ZEXPORT inflate(z_stream *strm, int flush)
                         break;
                     }
                     while (copy--)
-                        state->lens[state->have++] = (unsigned short)len;
+                        state->lens[state->have++] = (uint16_t)len;
                 }
             }
 
index dbd26f0b9281874cd5c23365ea8e1232f879f4d9..c6e7ff8e4ff3b6eaff943123d188c40fd085420e 100644 (file)
--- a/inflate.h
+++ b/inflate.h
@@ -112,9 +112,9 @@ struct inflate_state {
     unsigned nlen;              /* number of length code lengths */
     unsigned ndist;             /* number of distance code lengths */
     unsigned have;              /* number of code lengths in lens[] */
-    code *next;             /* next available space in codes[] */
-    unsigned short lens[320];   /* temporary storage for code lengths */
-    unsigned short work[288];   /* work area for code table building */
+    code *next;                 /* next available space in codes[] */
+    uint16_t lens[320];         /* temporary storage for code lengths */
+    uint16_t work[288];         /* work area for code table building */
     code codes[ENOUGH];         /* space for code tables */
     int sane;                   /* if false, allow invalid distance too far */
     int back;                   /* bits back of last unprocessed length/lit */
index 481659636feb1a27a32fcfe51dc480ceb7c294a0..bd651808bed0bc1936bd505fbc3fc4e87d3eba77 100644 (file)
@@ -29,8 +29,8 @@ const char inflate_copyright[] =
    table index bits.  It will differ if the request is greater than the
    longest code or if it is less than the shortest code.
  */
-int ZLIB_INTERNAL inflate_table(codetype type, unsigned short *lens, unsigned codes,
-                                code * *table, unsigned *bits, unsigned short  *work)
+int ZLIB_INTERNAL inflate_table(codetype type, uint16_t *lens, unsigned codes,
+                                code * *table, unsigned *bits, uint16_t  *work)
 {
     unsigned len;               /* a code's length in bits */
     unsigned sym;               /* index of code symbols */
@@ -46,23 +46,23 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short *lens, unsigned co
     unsigned low;               /* low bits for current root entry */
     unsigned mask;              /* mask for low root bits */
     code here;                  /* table entry for duplication */
-    code *next;             /* next available space in table */
-    const unsigned short *base;     /* base value table to use */
-    const unsigned short *extra;    /* extra bits table to use */
+    code *next;                 /* next available space in table */
+    const uint16_t *base;       /* base value table to use */
+    const uint16_t *extra;      /* extra bits table to use */
     int end;                    /* use base and extra for symbol > end */
-    unsigned short count[MAXBITS+1];    /* number of codes of each length */
-    unsigned short offs[MAXBITS+1];     /* offsets in table for each length */
-    static const unsigned short lbase[31] = { /* Length codes 257..285 base */
+    uint16_t count[MAXBITS+1];  /* number of codes of each length */
+    uint16_t offs[MAXBITS+1];   /* offsets in table for each length */
+    static const uint16_t lbase[31] = { /* Length codes 257..285 base */
         3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
         35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
-    static const unsigned short lext[31] = { /* Length codes 257..285 extra */
+    static const uint16_t lext[31] = { /* Length codes 257..285 extra */
         16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
         19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78};
-    static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
+    static const uint16_t dbase[32] = { /* Distance codes 0..29 base */
         1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
         257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
         8193, 12289, 16385, 24577, 0, 0};
-    static const unsigned short dext[32] = { /* Distance codes 0..29 extra */
+    static const uint16_t dext[32] = { /* Distance codes 0..29 extra */
         16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
         23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
         28, 28, 29, 29, 64, 64};
@@ -112,7 +112,7 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short *lens, unsigned co
     if (max == 0) {                     /* no symbols to code at all */
         here.op = (unsigned char)64;    /* invalid code marker */
         here.bits = (unsigned char)1;
-        here.val = (unsigned short)0;
+        here.val = (uint16_t)0;
         *(*table)++ = here;             /* make a table to force an error */
         *(*table)++ = here;
         *bits = 1;
@@ -139,7 +139,7 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short *lens, unsigned co
 
     /* sort symbols by length, by symbol order within each length */
     for (sym = 0; sym < codes; sym++)
-        if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym;
+        if (lens[sym] != 0) work[offs[lens[sym]]++] = (uint16_t)sym;
 
     /*
        Create and fill in decoding tables.  In this loop, the table being
@@ -280,7 +280,7 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short *lens, unsigned co
             low = huff & mask;
             (*table)[low].op = (unsigned char)curr;
             (*table)[low].bits = (unsigned char)root;
-            (*table)[low].val = (unsigned short)(next - *table);
+            (*table)[low].val = (uint16_t)(next - *table);
         }
     }
 
@@ -290,7 +290,7 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short *lens, unsigned co
     if (huff != 0) {
         here.op = (unsigned char)64;            /* invalid code marker */
         here.bits = (unsigned char)(len - drop);
-        here.val = (unsigned short)0;
+        here.val = (uint16_t)0;
         next[huff] = here;
     }
 
index a568d4094d3afabb9718833d8ccfdc5aeef13ea7..f266235ba78e892a9af390965e97d098704930fd 100644 (file)
@@ -22,9 +22,9 @@
    of a literal, the base length or distance, or the offset from
    the current table to the next table.  Each entry is four bytes. */
 typedef struct {
-    unsigned char op;           /* operation, extra bits, table bits */
-    unsigned char bits;         /* bits in this part of the code */
-    unsigned short val;         /* offset in table or code value */
+    unsigned char op;         /* operation, extra bits, table bits */
+    unsigned char bits;       /* bits in this part of the code */
+    uint16_t val;             /* offset in table or code value */
 } code;
 
 /* op values as set by inflate_table():
@@ -57,6 +57,5 @@ typedef enum {
     DISTS
 } codetype;
 
-int ZLIB_INTERNAL inflate_table (codetype type, unsigned short *lens,
-                             unsigned codes, code * *table,
-                             unsigned *bits, unsigned short *work);
+int ZLIB_INTERNAL inflate_table (codetype type, uint16_t *lens, unsigned codes,
+                                  code * *table, unsigned *bits, uint16_t *work);
diff --git a/match.c b/match.c
index 7a58b27633d7ef84626d7c21aa9f3eb9f4bf1131..a56d1b749e1720a529f94ad1d3d4be053f1aa7e0 100644 (file)
--- a/match.c
+++ b/match.c
@@ -156,7 +156,7 @@ ZLIB_INTERNAL unsigned longest_match(deflate_state *const s, IPos cur_match)
        const unsigned wmask = s->w_mask;
        const Pos *prev = s->prev;
 
-       unsigned short scan_start, scan_end;
+       uint16_t scan_start, scan_end;
        unsigned chain_length;
        IPos limit;
        unsigned int len, best_len, nice_match;
@@ -190,8 +190,8 @@ ZLIB_INTERNAL unsigned longest_match(deflate_state *const s, IPos cur_match)
 
        scan = s->window + s->strstart;
        strend = s->window + s->strstart + MAX_MATCH - 1;
-       scan_start = *(unsigned short *)scan;
-       scan_end = *(unsigned short *)(scan + best_len-1);
+       scan_start = *(uint16_t *)scan;
+       scan_end = *(uint16_t *)(scan + best_len-1);
 
        Assert((unsigned long)s->strstart <= s->window_size - MIN_LOOKAHEAD,
                "need lookahead");
@@ -210,9 +210,9 @@ ZLIB_INTERNAL unsigned longest_match(deflate_state *const s, IPos cur_match)
                 * is limited to the lookahead, so the output of deflate is not
                 * affected by the uninitialized values.
                 */
-               if (likely((*(unsigned short *)(match + best_len - 1) != scan_end)))
+               if (likely((*(uint16_t *)(match + best_len - 1) != scan_end)))
                        continue;
-               if (*(unsigned short *)match != scan_start)
+               if (*(uint16_t *)match != scan_start)
                        continue;
 
                /* It is not necessary to compare scan[2] and match[2] since
@@ -230,10 +230,10 @@ ZLIB_INTERNAL unsigned longest_match(deflate_state *const s, IPos cur_match)
                match++;
 
                do {
-               } while (*(unsigned short *)(scan += 2)== *(unsigned short *)(match += 2)&&
-                        *(unsigned short *)(scan += 2)== *(unsigned short *)(match += 2)&&
-                        *(unsigned short *)(scan += 2)== *(unsigned short *)(match += 2)&&
-                        *(unsigned short *)(scan += 2)== *(unsigned short *)(match += 2)&&
+               } while (*(uint16_t *)(scan += 2)== *(uint16_t *)(match += 2)&&
+                        *(uint16_t *)(scan += 2)== *(uint16_t *)(match += 2)&&
+                        *(uint16_t *)(scan += 2)== *(uint16_t *)(match += 2)&&
+                        *(uint16_t *)(scan += 2)== *(uint16_t *)(match += 2)&&
                         scan < strend);
 
                /*
@@ -251,7 +251,7 @@ ZLIB_INTERNAL unsigned longest_match(deflate_state *const s, IPos cur_match)
                        best_len = len;
                        if (len >= nice_match)
                                break;
-                       scan_end = *(unsigned short *)(scan + best_len - 1);
+                       scan_end = *(uint16_t *)(scan + best_len - 1);
                } else {
                        /*
                         * The probability of finding a match later if we here
@@ -351,8 +351,8 @@ ZLIB_INTERNAL unsigned longest_match(deflate_state *const s, IPos cur_match)
     uInt wmask = s->w_mask;
 
     register unsigned char *strend = s->window + s->strstart + MAX_MATCH;
-    register unsigned short scan_start = *(unsigned short*)scan;
-    register unsigned short scan_end   = *(unsigned short*)(scan+best_len-1);
+    register uint16_t scan_start = *(uint16_t*)scan;
+    register uint16_t scan_end   = *(uint16_t*)(scan+best_len-1);
 
     /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
      * It is easy to get rid of this optimization if necessary.
@@ -385,7 +385,7 @@ ZLIB_INTERNAL unsigned longest_match(deflate_state *const s, IPos cur_match)
         int cont = 1;
         do {
             match = win + cur_match;
-            if (likely(*(unsigned short*)(match+best_len-1) != scan_end)) {
+            if (likely(*(uint16_t*)(match+best_len-1) != scan_end)) {
                 if ((cur_match = prev[cur_match & wmask]) > limit
                     && --chain_length != 0) {
                     continue;
@@ -398,7 +398,7 @@ ZLIB_INTERNAL unsigned longest_match(deflate_state *const s, IPos cur_match)
         if (!cont)
             break;
 
-        if (*(unsigned short*)match != scan_start)
+        if (*(uint16_t*)match != scan_start)
             continue;
 
         /* It is not necessary to compare scan[2] and match[2] since they are
@@ -439,7 +439,7 @@ ZLIB_INTERNAL unsigned longest_match(deflate_state *const s, IPos cur_match)
             s->match_start = cur_match;
             best_len = len;
             if (len >= nice_match) break;
-            scan_end = *(unsigned short*)(scan+best_len-1);
+            scan_end = *(uint16_t*)(scan+best_len-1);
         } else {
             /*
              * The probability of finding a match later if we here
index 1786f0472bd3b1aa6d7f44a6d143bd0a54d71d46..fe4bf2de65c6c4bf31758c518ff8a56d86ffc76d 100644 (file)
@@ -631,13 +631,13 @@ static void cover_trees(void)
 {
     int ret;
     unsigned bits;
-    unsigned short lens[16], work[16];
+    uint16_t lens[16], work[16];
     code *next, table[ENOUGH_DISTS];
 
     /* we need to call inflate_table() directly in order to manifest not-
        enough errors, since zlib insures that enough is always enough */
     for (bits = 0; bits < 15; bits++)
-        lens[bits] = (unsigned short)(bits + 1);
+        lens[bits] = (uint16_t)(bits + 1);
     lens[15] = 15;
     next = table;
     bits = 15;