Skip to content

Commit

Permalink
Replace zlib with miniz.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Jun 16, 2012
1 parent 4e79a25 commit 161d956
Show file tree
Hide file tree
Showing 28 changed files with 723 additions and 10,734 deletions.
39 changes: 1 addition & 38 deletions CMakeLists.txt
Expand Up @@ -185,21 +185,6 @@ ELSE(MOJOSETUP_IS_BIGENDIAN)
ADD_DEFINITIONS(-DPLATFORM_LITTLEENDIAN=1)
ENDIF(MOJOSETUP_IS_BIGENDIAN)

SET(ZLIB_DIR zlib)
SET(ZLIB_SRCS
${ZLIB_DIR}/adler32.c
${ZLIB_DIR}/compress.c
${ZLIB_DIR}/crc32.c
${ZLIB_DIR}/deflate.c
${ZLIB_DIR}/infback.c
${ZLIB_DIR}/inffast.c
${ZLIB_DIR}/inflate.c
${ZLIB_DIR}/inftrees.c
${ZLIB_DIR}/trees.c
${ZLIB_DIR}/uncompr.c
${ZLIB_DIR}/zutil.c
)

SET(BZLIB_DIR bzip2)
SET(BZLIB_SRCS
${BZLIB_DIR}/blocksort.c
Expand Down Expand Up @@ -726,29 +711,7 @@ ENDIF(MOJOSETUP_USES_SOCKETS)
# Middleware...

IF(MOJOSETUP_NEED_ZLIB)
SET(HAVE_SYSTEM_ZLIB FALSE)
CHECK_INCLUDE_FILE(zlib.h HAVE_ZLIB_H)
IF(HAVE_ZLIB_H)
CHECK_LIBRARY_EXISTS("z" "inflate" "" HAVE_LIBZ)
IF(HAVE_LIBZ)
SET(HAVE_SYSTEM_ZLIB TRUE)
ENDIF(HAVE_LIBZ)
ENDIF(HAVE_ZLIB_H)

IF(HAVE_SYSTEM_ZLIB)
OPTION(MOJOSETUP_INTERNAL_ZLIB "Link own zlib instead of system library" FALSE)
ELSE(HAVE_SYSTEM_ZLIB)
SET(MOJOSETUP_INTERNAL_ZLIB TRUE)
ENDIF(HAVE_SYSTEM_ZLIB)

# BINARY SIZE += 50
IF(MOJOSETUP_INTERNAL_ZLIB)
INCLUDE_DIRECTORIES(${ZLIB_DIR})
ADD_DEFINITIONS(-DZ_PREFIX=1 -DZ_SOLO=1)
SET(OPTIONAL_SRCS ${OPTIONAL_SRCS} ${ZLIB_SRCS})
ELSE(MOJOSETUP_INTERNAL_ZLIB)
SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} z)
ENDIF(MOJOSETUP_INTERNAL_ZLIB)
SET(OPTIONAL_SRCS ${OPTIONAL_SRCS} miniz.c)
ENDIF(MOJOSETUP_NEED_ZLIB)

IF(MOJOSETUP_NEED_BZLIB)
Expand Down
2 changes: 1 addition & 1 deletion archive_uz2.c
Expand Up @@ -20,7 +20,7 @@ MojoArchive *MojoArchive_createUZ2(MojoInput *io) { return NULL; }
// uint8 data[compressed size] <-- unpacks to (uncompressed size) bytes.
// Decompression is handled by zlib's "uncompress" function.

#include "zlib/zlib.h"
#include "miniz.h"

#define MAXCOMPSIZE 32768
#define MAXUNCOMPSIZE 33096 // MAXCOMPSIZE + 1%
Expand Down
2 changes: 1 addition & 1 deletion archive_zip.c
Expand Up @@ -15,7 +15,7 @@ MojoArchive *MojoArchive_createZIP(MojoInput *io) { return NULL; }
#include <time.h>
#include <errno.h>

#include "zlib/zlib.h"
#include "miniz.h"

/*
* ZIP support routines, adapted from PhysicsFS (http://icculus.org/physfs/)
Expand Down
2 changes: 1 addition & 1 deletion fileio.c
Expand Up @@ -46,7 +46,7 @@ static const MojoArchiveType archives[] =

#if SUPPORT_GZIP

#include "zlib/zlib.h"
#include "miniz.h"

#define GZIP_READBUFSIZE (128 * 1024)

Expand Down
13 changes: 13 additions & 0 deletions miniz.c
@@ -0,0 +1,13 @@
/**
* MojoSetup; a portable, flexible installation application.
*
* Please see the file LICENSE.txt in the source's root directory.
*
* This file written by Ryan C. Gordon.
*/

#define MINIZ_INCLUDE_IMPLEMENTATION 1
#include "miniz.h"

// end of miniz.c ...

0 comments on commit 161d956

Please sign in to comment.