summaryrefslogtreecommitdiff
path: root/updater/bzip2-1.0.3/bzlib.c
diff options
context:
space:
mode:
author(no author) <(no author)@4f64403b-2f21-0410-a795-97e2b3489a10>2010-02-21 23:00:56 +0000
committer(no author) <(no author)@4f64403b-2f21-0410-a795-97e2b3489a10>2010-02-21 23:00:56 +0000
commit8f5a7b54eb953bbfc877ec915e26b3a95ec28d00 (patch)
tree827e40ab3528e10afd6fcb44f7ed5db0d7eed519 /updater/bzip2-1.0.3/bzlib.c
parentb130e8caa16961f597ae4ac6984a6aa00de7b6c7 (diff)
New updater with 3x reduced footprint and fully W7 and x64 compatible
git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@476 4f64403b-2f21-0410-a795-97e2b3489a10
Diffstat (limited to 'updater/bzip2-1.0.3/bzlib.c')
-rw-r--r--updater/bzip2-1.0.3/bzlib.c130
1 files changed, 43 insertions, 87 deletions
diff --git a/updater/bzip2-1.0.3/bzlib.c b/updater/bzip2-1.0.3/bzlib.c
index 1f6e9e4..ccc9afa 100644
--- a/updater/bzip2-1.0.3/bzlib.c
+++ b/updater/bzip2-1.0.3/bzlib.c
@@ -4,74 +4,29 @@
/*--- bzlib.c ---*/
/*-------------------------------------------------------------*/
-/*--
- This file is a part of bzip2 and/or libbzip2, a program and
- library for lossless, block-sorting data compression.
-
- Copyright (C) 1996-2005 Julian R Seward. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
- documentation would be appreciated but is not required.
-
- 3. Altered source versions must be plainly marked as such, and must
- not be misrepresented as being the original software.
-
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
- permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- Julian Seward, Cambridge, UK.
- jseward@bzip.org
- bzip2/libbzip2 version 1.0 of 21 March 2000
-
- This program is based on (at least) the work of:
- Mike Burrows
- David Wheeler
- Peter Fenwick
- Alistair Moffat
- Radford Neal
- Ian H. Witten
- Robert Sedgewick
- Jon L. Bentley
-
- For more information on these sources, see the manual.
---*/
+/* ------------------------------------------------------------------
+ This file is part of bzip2/libbzip2, a program and library for
+ lossless, block-sorting data compression.
-/*--
- CHANGES
- ~~~~~~~
- 0.9.0 -- original version.
+ bzip2/libbzip2 version 1.0.5 of 10 December 2007
+ Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org>
- 0.9.0a/b -- no changes in this file.
+ Please read the WARNING, DISCLAIMER and PATENTS sections in the
+ README file.
- 0.9.0c
- * made zero-length BZ_FLUSH work correctly in bzCompress().
- * fixed bzWrite/bzRead to ignore zero-length requests.
- * fixed bzread to correctly handle read requests after EOF.
- * wrong parameter order in call to bzDecompressInit in
- bzBuffToBuffDecompress. Fixed.
---*/
+ This program is released under the terms of the license contained
+ in the file LICENSE.
+ ------------------------------------------------------------------ */
+
+/* CHANGES
+ 0.9.0 -- original version.
+ 0.9.0a/b -- no changes in this file.
+ 0.9.0c -- made zero-length BZ_FLUSH work correctly in bzCompress().
+ fixed bzWrite/bzRead to ignore zero-length requests.
+ fixed bzread to correctly handle read requests after EOF.
+ wrong parameter order in call to bzDecompressInit in
+ bzBuffToBuffDecompress. Fixed.
+*/
#include "bzlib_private.h"
@@ -93,7 +48,7 @@ void BZ2_bz__AssertH__fail ( int errcode )
"component, you should also report this bug to the author(s)\n"
"of that program. Please make an effort to report this bug;\n"
"timely and accurate bug reports eventually lead to higher\n"
- "quality software. Thanks. Julian Seward, 15 February 2005.\n\n",
+ "quality software. Thanks. Julian Seward, 10 December 2007.\n\n",
errcode,
BZ2_bzlibVersion()
);
@@ -210,7 +165,7 @@ int BZ_API(BZ2_bzCompressInit)
if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc;
if (strm->bzfree == NULL) strm->bzfree = default_bzfree;
- s = (EState *)BZALLOC( sizeof(EState) );
+ s = BZALLOC( sizeof(EState) );
if (s == NULL) return BZ_MEM_ERROR;
s->strm = strm;
@@ -219,9 +174,9 @@ int BZ_API(BZ2_bzCompressInit)
s->ftab = NULL;
n = 100000 * blockSize100k;
- s->arr1 = (UInt32 *)BZALLOC( n * sizeof(UInt32) );
- s->arr2 = (UInt32 *)BZALLOC( (n+BZ_N_OVERSHOOT) * sizeof(UInt32) );
- s->ftab = (UInt32 *)BZALLOC( 65537 * sizeof(UInt32) );
+ s->arr1 = BZALLOC( n * sizeof(UInt32) );
+ s->arr2 = BZALLOC( (n+BZ_N_OVERSHOOT) * sizeof(UInt32) );
+ s->ftab = BZALLOC( 65537 * sizeof(UInt32) );
if (s->arr1 == NULL || s->arr2 == NULL || s->ftab == NULL) {
if (s->arr1 != NULL) BZFREE(s->arr1);
@@ -407,7 +362,7 @@ Bool handle_compress ( bz_stream* strm )
{
Bool progress_in = False;
Bool progress_out = False;
- EState* s = (EState *)strm->state;
+ EState* s = strm->state;
while (True) {
@@ -454,7 +409,7 @@ int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action )
Bool progress;
EState* s;
if (strm == NULL) return BZ_PARAM_ERROR;
- s = (EState *)strm->state;
+ s = strm->state;
if (s == NULL) return BZ_PARAM_ERROR;
if (s->strm != strm) return BZ_PARAM_ERROR;
@@ -514,7 +469,7 @@ int BZ_API(BZ2_bzCompressEnd) ( bz_stream *strm )
{
EState* s;
if (strm == NULL) return BZ_PARAM_ERROR;
- s = (EState *)strm->state;
+ s = strm->state;
if (s == NULL) return BZ_PARAM_ERROR;
if (s->strm != strm) return BZ_PARAM_ERROR;
@@ -550,7 +505,7 @@ int BZ_API(BZ2_bzDecompressInit)
if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc;
if (strm->bzfree == NULL) strm->bzfree = default_bzfree;
- s = (DState *)BZALLOC( sizeof(DState) );
+ s = BZALLOC( sizeof(DState) );
if (s == NULL) return BZ_MEM_ERROR;
s->strm = strm;
strm->state = s;
@@ -643,6 +598,7 @@ Bool unRLE_obuf_to_output_FAST ( DState* s )
UInt32 c_tPos = s->tPos;
char* cs_next_out = s->strm->next_out;
unsigned int cs_avail_out = s->strm->avail_out;
+ Int32 ro_blockSize100k = s->blockSize100k;
/* end restore */
UInt32 avail_out_INIT = cs_avail_out;
@@ -854,7 +810,7 @@ int BZ_API(BZ2_bzDecompress) ( bz_stream *strm )
Bool corrupt;
DState* s;
if (strm == NULL) return BZ_PARAM_ERROR;
- s = (DState *)strm->state;
+ s = strm->state;
if (s == NULL) return BZ_PARAM_ERROR;
if (s->strm != strm) return BZ_PARAM_ERROR;
@@ -907,7 +863,7 @@ int BZ_API(BZ2_bzDecompressEnd) ( bz_stream *strm )
{
DState* s;
if (strm == NULL) return BZ_PARAM_ERROR;
- s = (DState *)strm->state;
+ s = strm->state;
if (s == NULL) return BZ_PARAM_ERROR;
if (s->strm != strm) return BZ_PARAM_ERROR;
@@ -978,7 +934,7 @@ BZFILE* BZ_API(BZ2_bzWriteOpen)
if (ferror(f))
{ BZ_SETERR(BZ_IO_ERROR); return NULL; };
- bzf = (bzFile *)malloc ( sizeof(bzFile) );
+ bzf = malloc ( sizeof(bzFile) );
if (bzf == NULL)
{ BZ_SETERR(BZ_MEM_ERROR); return NULL; };
@@ -1026,7 +982,7 @@ void BZ_API(BZ2_bzWrite)
{ BZ_SETERR(BZ_OK); return; };
bzf->strm.avail_in = len;
- bzf->strm.next_in = (char *)buf;
+ bzf->strm.next_in = buf;
while (True) {
bzf->strm.avail_out = BZ_MAX_UNUSED;
@@ -1151,7 +1107,7 @@ BZFILE* BZ_API(BZ2_bzReadOpen)
if (ferror(f))
{ BZ_SETERR(BZ_IO_ERROR); return NULL; };
- bzf = (bzFile *)malloc ( sizeof(bzFile) );
+ bzf = malloc ( sizeof(bzFile) );
if (bzf == NULL)
{ BZ_SETERR(BZ_MEM_ERROR); return NULL; };
@@ -1223,7 +1179,7 @@ int BZ_API(BZ2_bzRead)
{ BZ_SETERR(BZ_OK); return 0; };
bzf->strm.avail_out = len;
- bzf->strm.next_out = (char *)buf;
+ bzf->strm.next_out = buf;
while (True) {
@@ -1394,8 +1350,7 @@ int BZ_API(BZ2_bzBuffToBuffDecompress)
/*---------------------------------------------------*/
/*--
- Code contributed by Yoshioka Tsuneo
- (QWF00133@niftyserve.or.jp/tsuneo-y@is.aist-nara.ac.jp),
+ Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp)
to support better zlib compatibility.
This code is not _officially_ part of libbzip2 (yet);
I haven't tested it, documented it, or considered the
@@ -1406,7 +1361,7 @@ int BZ_API(BZ2_bzBuffToBuffDecompress)
/*---------------------------------------------------*/
/*--
- return version like "0.9.0c".
+ return version like "0.9.5d, 4-Sept-1999".
--*/
const char * BZ_API(BZ2_bzlibVersion)(void)
{
@@ -1420,7 +1375,7 @@ const char * BZ_API(BZ2_bzlibVersion)(void)
#if defined(_WIN32) || defined(OS2) || defined(MSDOS)
# include <fcntl.h>
# include <io.h>
-# define SET_BINARY_MODE(file) setmode(fileno(file),O_BINARY)
+# define SET_BINARY_MODE(file) _setmode(_fileno(file),O_BINARY)
#else
# define SET_BINARY_MODE(file)
#endif
@@ -1473,7 +1428,7 @@ BZFILE * bzopen_or_bzdopen
#ifdef BZ_STRICT_ANSI
fp = NULL;
#else
- fp = fdopen(fd,mode2);
+ fp = _fdopen(fd,mode2);
#endif
}
if (fp == NULL) return NULL;
@@ -1559,9 +1514,10 @@ int BZ_API(BZ2_bzflush) (BZFILE *b)
void BZ_API(BZ2_bzclose) (BZFILE* b)
{
int bzerr;
- FILE *fp = ((bzFile *)b)->handle;
+ FILE *fp;
if (b==NULL) {return;}
+ fp = ((bzFile *)b)->handle;
if(((bzFile*)b)->writing){
BZ2_bzWriteClose(&bzerr,b,0,NULL,NULL);
if(bzerr != BZ_OK){
@@ -1580,7 +1536,7 @@ void BZ_API(BZ2_bzclose) (BZFILE* b)
/*--
return last error code
--*/
-static char *bzerrorstrings[] = {
+static const char *bzerrorstrings[] = {
"OK"
,"SEQUENCE_ERROR"
,"PARAM_ERROR"