diff options
author | Toomas Soome <tsoome@me.com> | 2016-10-31 11:32:03 +0200 |
---|---|---|
committer | Richard Lowe <richlowe@richlowe.net> | 2016-11-26 13:35:24 -0500 |
commit | fce880d1411ac6f72a4f06d50af95f9912093f9f (patch) | |
tree | 65c2d4b66f0bb6689322c4331e1ae923b7bce9c9 | |
parent | 2de8d7230f771f0640dc41231b6f4743c3f1afad (diff) | |
download | illumos-joyent-fce880d1411ac6f72a4f06d50af95f9912093f9f.tar.gz |
7526 bzip2 should have way to hide the compression support
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
-rw-r--r-- | usr/src/common/bzip2/bzlib.c | 66 |
1 files changed, 38 insertions, 28 deletions
diff --git a/usr/src/common/bzip2/bzlib.c b/usr/src/common/bzip2/bzlib.c index be878f92c4..22e2d8826e 100644 --- a/usr/src/common/bzip2/bzlib.c +++ b/usr/src/common/bzip2/bzlib.c @@ -30,6 +30,7 @@ #include "bzlib_private.h" +#ifndef BZ_NO_COMPRESS /*---------------------------------------------------*/ /*--- Compression stuff ---*/ @@ -85,6 +86,7 @@ void BZ2_bz__AssertH__fail ( int errcode ) } #endif +#endif /* BZ_NO_COMPRESS */ /*---------------------------------------------------*/ static @@ -193,6 +195,7 @@ void default_bzfree ( void* opaque, void* addr ) #endif /* _KERNEL */ /*---------------------------------------------------*/ +#ifndef BZ_NO_COMPRESS static void prepare_new_block ( EState* s ) { @@ -346,34 +349,6 @@ int BZ_API(BZ2_bzCompressReset) ( bz_stream *strm ) return BZ_OK; } -int BZ_API(BZ2_bzDecompressReset) ( bz_stream* strm ) -{ - DState* s = strm->state; - - if (!bz_config_ok()) return BZ_CONFIG_ERROR; - - if (strm == NULL) return BZ_PARAM_ERROR; - - s->strm = strm; - - s->state = BZ_X_MAGIC_1; - s->bsLive = 0; - s->bsBuff = 0; - s->calculatedCombinedCRC = 0; - strm->total_in_lo32 = 0; - strm->total_in_hi32 = 0; - strm->total_out_lo32 = 0; - strm->total_out_hi32 = 0; - - s->ll4 = NULL; - s->ll16 = NULL; - s->tt = NULL; - s->currBlockNo = 0; - - - return BZ_OK; -} - /*---------------------------------------------------*/ static @@ -647,6 +622,7 @@ int BZ_API(BZ2_bzCompressEnd) ( bz_stream *strm ) return BZ_OK; } +#endif /* BZ_NO_COMPRESS */ /*---------------------------------------------------*/ /*--- Decompression stuff ---*/ @@ -691,6 +667,38 @@ int BZ_API(BZ2_bzDecompressInit) return BZ_OK; } +/*---------------------------------------------------*/ +/* + * added to allow reuse of bz_stream without malloc/free + */ +int BZ_API(BZ2_bzDecompressReset) ( bz_stream* strm ) +{ + DState* s = strm->state; + + if (!bz_config_ok()) return BZ_CONFIG_ERROR; + + if (strm == NULL) return BZ_PARAM_ERROR; + + s->strm = strm; + + s->state = BZ_X_MAGIC_1; + s->bsLive = 0; + s->bsBuff = 0; + s->calculatedCombinedCRC = 0; + strm->total_in_lo32 = 0; + strm->total_in_hi32 = 0; + strm->total_out_lo32 = 0; + strm->total_out_hi32 = 0; + + s->ll4 = NULL; + s->ll16 = NULL; + s->tt = NULL; + s->currBlockNo = 0; + + + return BZ_OK; +} + /*---------------------------------------------------*/ /* Return True iff data corruption is discovered. @@ -1043,6 +1051,7 @@ int BZ_API(BZ2_bzDecompressEnd) ( bz_stream *strm ) return BZ_OK; } +#ifndef BZ_NO_COMPRESS #ifndef BZ_NO_STDIO /*---------------------------------------------------*/ @@ -1732,6 +1741,7 @@ const char * BZ_API(BZ2_bzerror) (BZFILE *b, int *errnum) } #endif +#endif /* BZ_NO_COMPRESS */ /*-------------------------------------------------------------*/ /*--- end bzlib.c ---*/ |