diff options
-rw-r--r-- | deflate.c | 22 | ||||
-rw-r--r-- | deflate.h | 5 | ||||
-rw-r--r-- | trees.c | 7 | ||||
-rw-r--r-- | zlib.h | 5 |
4 files changed, 26 insertions, 13 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* deflate.c -- compress data using the deflation algorithm | 1 | /* deflate.c -- compress data using the deflation algorithm |
2 | * Copyright (C) 1995-2011 Jean-loup Gailly and Mark Adler | 2 | * Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler |
3 | * For conditions of distribution and use, see copyright notice in zlib.h | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
4 | */ | 4 | */ |
5 | 5 | ||
@@ -52,7 +52,7 @@ | |||
52 | #include "deflate.h" | 52 | #include "deflate.h" |
53 | 53 | ||
54 | const char deflate_copyright[] = | 54 | const char deflate_copyright[] = |
55 | " deflate 1.2.5.3 Copyright 1995-2011 Jean-loup Gailly and Mark Adler "; | 55 | " deflate 1.2.5.3 Copyright 1995-2012 Jean-loup Gailly and Mark Adler "; |
56 | /* | 56 | /* |
57 | If you use the zlib library in a product, an acknowledgment is welcome | 57 | If you use the zlib library in a product, an acknowledgment is welcome |
58 | in the documentation of your product. If for some reason you cannot | 58 | in the documentation of your product. If for some reason you cannot |
@@ -464,9 +464,23 @@ int ZEXPORT deflatePrime (strm, bits, value) | |||
464 | int bits; | 464 | int bits; |
465 | int value; | 465 | int value; |
466 | { | 466 | { |
467 | deflate_state *s; | ||
468 | int put; | ||
469 | |||
467 | if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; | 470 | if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; |
468 | strm->state->bi_valid = bits; | 471 | s = strm->state; |
469 | strm->state->bi_buf = (ush)(value & ((1 << bits) - 1)); | 472 | if ((Bytef *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3)) |
473 | return Z_BUF_ERROR; | ||
474 | do { | ||
475 | put = Buf_size - s->bi_valid; | ||
476 | if (put > bits) | ||
477 | put = bits; | ||
478 | s->bi_buf |= (ush)((value & ((1 << put) - 1)) << s->bi_valid); | ||
479 | s->bi_valid += put; | ||
480 | _tr_flush_bits(s); | ||
481 | value >>= put; | ||
482 | bits -= put; | ||
483 | } while (bits); | ||
470 | return Z_OK; | 484 | return Z_OK; |
471 | } | 485 | } |
472 | 486 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* deflate.h -- internal compression state | 1 | /* deflate.h -- internal compression state |
2 | * Copyright (C) 1995-2010 Jean-loup Gailly | 2 | * Copyright (C) 1995-2012 Jean-loup Gailly |
3 | * For conditions of distribution and use, see copyright notice in zlib.h | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
4 | */ | 4 | */ |
5 | 5 | ||
@@ -48,6 +48,9 @@ | |||
48 | #define MAX_BITS 15 | 48 | #define MAX_BITS 15 |
49 | /* All codes must not exceed MAX_BITS bits */ | 49 | /* All codes must not exceed MAX_BITS bits */ |
50 | 50 | ||
51 | #define Buf_size 16 | ||
52 | /* size of bit buffer in bi_buf */ | ||
53 | |||
51 | #define INIT_STATE 42 | 54 | #define INIT_STATE 42 |
52 | #define EXTRA_STATE 69 | 55 | #define EXTRA_STATE 69 |
53 | #define NAME_STATE 73 | 56 | #define NAME_STATE 73 |
@@ -1,5 +1,5 @@ | |||
1 | /* trees.c -- output deflated data using Huffman coding | 1 | /* trees.c -- output deflated data using Huffman coding |
2 | * Copyright (C) 1995-2010 Jean-loup Gailly | 2 | * Copyright (C) 1995-2012 Jean-loup Gailly |
3 | * detect_data_type() function provided freely by Cosmin Truta, 2006 | 3 | * detect_data_type() function provided freely by Cosmin Truta, 2006 |
4 | * For conditions of distribution and use, see copyright notice in zlib.h | 4 | * For conditions of distribution and use, see copyright notice in zlib.h |
5 | */ | 5 | */ |
@@ -74,11 +74,6 @@ local const uch bl_order[BL_CODES] | |||
74 | * probability, to avoid transmitting the lengths for unused bit length codes. | 74 | * probability, to avoid transmitting the lengths for unused bit length codes. |
75 | */ | 75 | */ |
76 | 76 | ||
77 | #define Buf_size (8 * 2*sizeof(char)) | ||
78 | /* Number of bits used within bi_buf. (bi_buf might be implemented on | ||
79 | * more than 16 bits on some systems.) | ||
80 | */ | ||
81 | |||
82 | /* =========================================================================== | 77 | /* =========================================================================== |
83 | * Local data. These are initialized only once. | 78 | * Local data. These are initialized only once. |
84 | */ | 79 | */ |
@@ -734,8 +734,9 @@ ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, | |||
734 | than or equal to 16, and that many of the least significant bits of value | 734 | than or equal to 16, and that many of the least significant bits of value |
735 | will be inserted in the output. | 735 | will be inserted in the output. |
736 | 736 | ||
737 | deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source | 737 | deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough |
738 | stream state was inconsistent. | 738 | room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the |
739 | source stream state was inconsistent. | ||
739 | */ | 740 | */ |
740 | 741 | ||
741 | ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, | 742 | ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, |