summaryrefslogtreecommitdiffstats
path: root/src/misc/bzlib
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2010-11-01 01:35:04 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2010-11-01 01:35:04 -0700
commit6130e39b18b5f53902e4eab14f6d5cdde5219563 (patch)
tree0db0628479a1b750e9af1f66cb8379ebd0913d31 /src/misc/bzlib
parentf0e77f6797c0504b0da25a56152b707d3357f386 (diff)
downloadabc-6130e39b18b5f53902e4eab14f6d5cdde5219563.tar.gz
abc-6130e39b18b5f53902e4eab14f6d5cdde5219563.tar.bz2
abc-6130e39b18b5f53902e4eab14f6d5cdde5219563.zip
initial commit of public abc
Diffstat (limited to 'src/misc/bzlib')
-rw-r--r--src/misc/bzlib/blocksort.c4
-rw-r--r--src/misc/bzlib/bzlib.c45
-rw-r--r--src/misc/bzlib/bzlib.h14
-rw-r--r--src/misc/bzlib/bzlib_private.h8
-rw-r--r--src/misc/bzlib/compress.c5
-rw-r--r--src/misc/bzlib/crctable.c5
-rw-r--r--src/misc/bzlib/decompress.c11
-rw-r--r--src/misc/bzlib/huffman.c5
-rw-r--r--src/misc/bzlib/randtable.c5
9 files changed, 74 insertions, 28 deletions
diff --git a/src/misc/bzlib/blocksort.c b/src/misc/bzlib/blocksort.c
index 95adb5ef..0dc4ff46 100644
--- a/src/misc/bzlib/blocksort.c
+++ b/src/misc/bzlib/blocksort.c
@@ -21,6 +21,8 @@
#include "bzlib_private.h"
+ABC_NAMESPACE_IMPL_START
+
/*---------------------------------------------*/
/*--- Fallback O(N log(N)^2) sorting ---*/
/*--- algorithm, for repetitive blocks ---*/
@@ -1092,3 +1094,5 @@ void BZ2_blockSort ( EState* s )
/*-------------------------------------------------------------*/
/*--- end blocksort.c ---*/
/*-------------------------------------------------------------*/
+
+ABC_NAMESPACE_IMPL_END
diff --git a/src/misc/bzlib/bzlib.c b/src/misc/bzlib/bzlib.c
index 9d040682..93aa083d 100644
--- a/src/misc/bzlib/bzlib.c
+++ b/src/misc/bzlib/bzlib.c
@@ -30,6 +30,14 @@
#include "bzlib_private.h"
+ABC_NAMESPACE_IMPL_START
+
+#ifdef _WIN32
+#define fileno _fileno
+#define fdopen _fdopen
+#define setmode _setmode
+#endif
+
/*---------------------------------------------------*/
/*--- Compression stuff ---*/
/*---------------------------------------------------*/
@@ -164,7 +172,7 @@ int BZ_API(BZ2_bzCompressInit)
if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc;
if (strm->bzfree == NULL) strm->bzfree = default_bzfree;
- s = BZALLOC( sizeof(EState) );
+ s = (EState *)BZALLOC( sizeof(EState) );
if (s == NULL) return BZ_MEM_ERROR;
s->strm = strm;
@@ -173,9 +181,9 @@ int BZ_API(BZ2_bzCompressInit)
s->ftab = NULL;
n = 100000 * blockSize100k;
- s->arr1 = BZALLOC( n * sizeof(UInt32) );
- s->arr2 = BZALLOC( (n+BZ_N_OVERSHOOT) * sizeof(UInt32) );
- s->ftab = BZALLOC( 65537 * sizeof(UInt32) );
+ s->arr1 = (unsigned *)BZALLOC( n * sizeof(UInt32) );
+ s->arr2 = (unsigned *)BZALLOC( (n+BZ_N_OVERSHOOT) * sizeof(UInt32) );
+ s->ftab = (unsigned *)BZALLOC( 65537 * sizeof(UInt32) );
if (s->arr1 == NULL || s->arr2 == NULL || s->ftab == NULL) {
if (s->arr1 != NULL) BZFREE(s->arr1);
@@ -361,7 +369,7 @@ Bool handle_compress ( bz_stream* strm )
{
Bool progress_in = False;
Bool progress_out = False;
- EState* s = strm->state;
+ EState* s = (EState *)strm->state;
while (True) {
@@ -408,7 +416,7 @@ int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action )
Bool progress;
EState* s;
if (strm == NULL) return BZ_PARAM_ERROR;
- s = strm->state;
+ s = (EState *)strm->state;
if (s == NULL) return BZ_PARAM_ERROR;
if (s->strm != strm) return BZ_PARAM_ERROR;
@@ -468,7 +476,7 @@ int BZ_API(BZ2_bzCompressEnd) ( bz_stream *strm )
{
EState* s;
if (strm == NULL) return BZ_PARAM_ERROR;
- s = strm->state;
+ s = (EState *)strm->state;
if (s == NULL) return BZ_PARAM_ERROR;
if (s->strm != strm) return BZ_PARAM_ERROR;
@@ -504,7 +512,7 @@ int BZ_API(BZ2_bzDecompressInit)
if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc;
if (strm->bzfree == NULL) strm->bzfree = default_bzfree;
- s = BZALLOC( sizeof(DState) );
+ s = (DState *)BZALLOC( sizeof(DState) );
if (s == NULL) return BZ_MEM_ERROR;
s->strm = strm;
strm->state = s;
@@ -683,7 +691,7 @@ Bool unRLE_obuf_to_output_FAST ( DState* s )
/*---------------------------------------------------*/
-__inline__ Int32 BZ2_indexIntoF ( Int32 indx, Int32 *cftab )
+Int32 BZ2_indexIntoF ( Int32 indx, Int32 *cftab )
{
Int32 nb, na, mid;
nb = 0;
@@ -809,7 +817,7 @@ int BZ_API(BZ2_bzDecompress) ( bz_stream *strm )
Bool corrupt;
DState* s;
if (strm == NULL) return BZ_PARAM_ERROR;
- s = strm->state;
+ s = (DState *)strm->state;
if (s == NULL) return BZ_PARAM_ERROR;
if (s->strm != strm) return BZ_PARAM_ERROR;
@@ -862,7 +870,7 @@ int BZ_API(BZ2_bzDecompressEnd) ( bz_stream *strm )
{
DState* s;
if (strm == NULL) return BZ_PARAM_ERROR;
- s = strm->state;
+ s = (DState *)strm->state;
if (s == NULL) return BZ_PARAM_ERROR;
if (s->strm != strm) return BZ_PARAM_ERROR;
@@ -933,7 +941,7 @@ BZFILE* BZ_API(BZ2_bzWriteOpen)
if (ferror(f))
{ BZ_SETERR(BZ_IO_ERROR); return NULL; };
- bzf = malloc ( sizeof(bzFile) );
+ bzf = (bzFile *)malloc ( sizeof(bzFile) );
if (bzf == NULL)
{ BZ_SETERR(BZ_MEM_ERROR); return NULL; };
@@ -981,7 +989,7 @@ void BZ_API(BZ2_bzWrite)
{ BZ_SETERR(BZ_OK); return; };
bzf->strm.avail_in = len;
- bzf->strm.next_in = buf;
+ bzf->strm.next_in = (char *)buf;
while (True) {
bzf->strm.avail_out = BZ_MAX_UNUSED;
@@ -1106,7 +1114,7 @@ BZFILE* BZ_API(BZ2_bzReadOpen)
if (ferror(f))
{ BZ_SETERR(BZ_IO_ERROR); return NULL; };
- bzf = malloc ( sizeof(bzFile) );
+ bzf = (bzFile *)malloc ( sizeof(bzFile) );
if (bzf == NULL)
{ BZ_SETERR(BZ_MEM_ERROR); return NULL; };
@@ -1178,7 +1186,7 @@ int BZ_API(BZ2_bzRead)
{ BZ_SETERR(BZ_OK); return 0; };
bzf->strm.avail_out = len;
- bzf->strm.next_out = buf;
+ bzf->strm.next_out = (char *)buf;
while (True) {
@@ -1427,7 +1435,7 @@ BZFILE * bzopen_or_bzdopen
#ifdef BZ_STRICT_ANSI
fp = NULL;
#else
- fp = fdopen(fd,mode2);
+ fp = (FILE *)fdopen(fd,mode2);
#endif
}
if (fp == NULL) return NULL;
@@ -1569,3 +1577,8 @@ const char * BZ_API(BZ2_bzerror) (BZFILE *b, int *errnum)
/*-------------------------------------------------------------*/
/*--- end bzlib.c ---*/
/*-------------------------------------------------------------*/
+
+ABC_NAMESPACE_IMPL_END
+
+
+
diff --git a/src/misc/bzlib/bzlib.h b/src/misc/bzlib/bzlib.h
index b1f892b0..68a6cd01 100644
--- a/src/misc/bzlib/bzlib.h
+++ b/src/misc/bzlib/bzlib.h
@@ -27,10 +27,6 @@
#ifndef _BZLIB_H
#define _BZLIB_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#define BZ_RUN 0
#define BZ_FLUSH 1
#define BZ_FINISH 2
@@ -99,6 +95,10 @@ typedef
# define BZ_EXTERN extern
#endif
+#include <stdio.h>
+#include "abc_global.h"
+
+ABC_NAMESPACE_HEADER_START
/*-- Core (low-level) library functions --*/
@@ -276,9 +276,9 @@ BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
);
#endif
-#ifdef __cplusplus
-}
-#endif
+
+ABC_NAMESPACE_HEADER_END
+
#endif
diff --git a/src/misc/bzlib/bzlib_private.h b/src/misc/bzlib/bzlib_private.h
index 23427879..072f0486 100644
--- a/src/misc/bzlib/bzlib_private.h
+++ b/src/misc/bzlib/bzlib_private.h
@@ -22,6 +22,7 @@
#ifndef _BZLIB_PRIVATE_H
#define _BZLIB_PRIVATE_H
+
#include <stdlib.h>
#ifndef BZ_NO_STDIO
@@ -30,9 +31,10 @@
#include <string.h>
#endif
-#include "bzlib.h"
+#include "bzlib.h"
+ABC_NAMESPACE_HEADER_START
/*-- General stuff. --*/
@@ -481,7 +483,7 @@ typedef
/*-- externs for decompression. --*/
-extern Int32
+Int32
BZ2_indexIntoF ( Int32, Int32* );
extern Int32
@@ -501,8 +503,10 @@ BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*,
#ifndef NULL
#define NULL 0
#endif
+
#endif
+ABC_NAMESPACE_HEADER_END
/*-------------------------------------------------------------*/
/*--- end bzlib_private.h ---*/
diff --git a/src/misc/bzlib/compress.c b/src/misc/bzlib/compress.c
index 7d9b3da7..b149a28c 100644
--- a/src/misc/bzlib/compress.c
+++ b/src/misc/bzlib/compress.c
@@ -28,6 +28,9 @@
#include "bzlib_private.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------*/
/*--- Bit stream I/O ---*/
@@ -670,3 +673,5 @@ void BZ2_compressBlock ( EState* s, Bool is_last_block )
/*-------------------------------------------------------------*/
/*--- end compress.c ---*/
/*-------------------------------------------------------------*/
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/bzlib/crctable.c b/src/misc/bzlib/crctable.c
index 215687b2..6e033d0d 100644
--- a/src/misc/bzlib/crctable.c
+++ b/src/misc/bzlib/crctable.c
@@ -21,6 +21,9 @@
#include "bzlib_private.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*--
I think this is an implementation of the AUTODIN-II,
Ethernet & FDDI 32-bit CRC standard. Vaguely derived
@@ -102,3 +105,5 @@ UInt32 BZ2_crc32Table[256] = {
/*-------------------------------------------------------------*/
/*--- end crctable.c ---*/
/*-------------------------------------------------------------*/
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/bzlib/decompress.c b/src/misc/bzlib/decompress.c
index bba5e0fa..47dd98e4 100644
--- a/src/misc/bzlib/decompress.c
+++ b/src/misc/bzlib/decompress.c
@@ -21,6 +21,9 @@
#include "bzlib_private.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------*/
static
@@ -209,13 +212,13 @@ Int32 BZ2_decompress ( DState* s )
s->blockSize100k -= BZ_HDR_0;
if (s->smallDecompress) {
- s->ll16 = BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) );
- s->ll4 = BZALLOC(
+ s->ll16 = (unsigned short *)BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) );
+ s->ll4 = (unsigned char *)BZALLOC(
((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar)
);
if (s->ll16 == NULL || s->ll4 == NULL) RETURN(BZ_MEM_ERROR);
} else {
- s->tt = BZALLOC( s->blockSize100k * 100000 * sizeof(Int32) );
+ s->tt = (unsigned *)BZALLOC( s->blockSize100k * 100000 * sizeof(Int32) );
if (s->tt == NULL) RETURN(BZ_MEM_ERROR);
}
@@ -624,3 +627,5 @@ Int32 BZ2_decompress ( DState* s )
/*-------------------------------------------------------------*/
/*--- end decompress.c ---*/
/*-------------------------------------------------------------*/
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/bzlib/huffman.c b/src/misc/bzlib/huffman.c
index 87e79e38..0f367d62 100644
--- a/src/misc/bzlib/huffman.c
+++ b/src/misc/bzlib/huffman.c
@@ -21,6 +21,9 @@
#include "bzlib_private.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------*/
#define WEIGHTOF(zz0) ((zz0) & 0xffffff00)
#define DEPTHOF(zz1) ((zz1) & 0x000000ff)
@@ -203,3 +206,5 @@ void BZ2_hbCreateDecodeTables ( Int32 *limit,
/*-------------------------------------------------------------*/
/*--- end huffman.c ---*/
/*-------------------------------------------------------------*/
+
+ABC_NAMESPACE_IMPL_END
diff --git a/src/misc/bzlib/randtable.c b/src/misc/bzlib/randtable.c
index 068b7636..9cabcb69 100644
--- a/src/misc/bzlib/randtable.c
+++ b/src/misc/bzlib/randtable.c
@@ -21,6 +21,9 @@
#include "bzlib_private.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------*/
Int32 BZ2_rNums[512] = {
@@ -82,3 +85,5 @@ Int32 BZ2_rNums[512] = {
/*-------------------------------------------------------------*/
/*--- end randtable.c ---*/
/*-------------------------------------------------------------*/
+ABC_NAMESPACE_IMPL_END
+