diff options
Diffstat (limited to 'deflate.c')
-rw-r--r-- | deflate.c | 22 |
1 files changed, 18 insertions, 4 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 | ||