Skip to content

Commit

Permalink
Replace defines with function wrappers etc. as much as possible
Browse files Browse the repository at this point in the history
  • Loading branch information
uroni committed Dec 6, 2024
1 parent 0f4cbb8 commit 2fa13ca
Showing 1 changed file with 94 additions and 22 deletions.
116 changes: 94 additions & 22 deletions miniz.h
Original file line number Diff line number Diff line change
Expand Up @@ -479,44 +479,116 @@ extern "C"
#define Z_FIXED MZ_FIXED
#define Z_DEFLATED MZ_DEFLATED
#define Z_DEFAULT_WINDOW_BITS MZ_DEFAULT_WINDOW_BITS
#define alloc_func mz_alloc_func
#define free_func mz_free_func
/* See mz_alloc_func */
typedef void *(*alloc_func)(void *opaque, size_t items, size_t size);
/* See mz_free_func */
typedef void (*free_func)(void *opaque, void *address);

#define internal_state mz_internal_state
#define z_stream mz_stream

#ifndef MINIZ_NO_DEFLATE_APIS
#define deflateInit mz_deflateInit
#define deflateInit2 mz_deflateInit2
#define deflateReset mz_deflateReset
#define deflate mz_deflate
#define deflateEnd mz_deflateEnd
#define deflateBound mz_deflateBound
#define compress mz_compress
#define compress2 mz_compress2
#define compressBound mz_compressBound
/* Compatiblity with zlib API. See called functions for documentation */
static int deflateInit(mz_streamp pStream, int level)
{
return mz_deflateInit(pStream, level);
}
static int deflateInit2(mz_streamp pStream, int level, int method, int window_bits, int mem_level, int strategy)
{
return mz_deflateInit2(pStream, level, method, window_bits, mem_level, strategy);
}
static int deflateReset(mz_streamp pStream)
{
return mz_deflateReset(pStream);
}
static int deflate(mz_streamp pStream, int flush)
{
return mz_deflate(pStream, flush);
}
static int deflateEnd(mz_streamp pStream)
{
return mz_deflateEnd(pStream);
}
static mz_ulong deflateBound(mz_streamp pStream, mz_ulong source_len)
{
return mz_deflateBound(pStream, source_len);
}
static int compress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len)
{
return mz_compress(pDest, pDest_len, pSource, source_len);
}
static int compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len, int level)
{
return mz_compress2(pDest, pDest_len, pSource, source_len, level);
}
static mz_ulong compressBound(mz_ulong source_len)
{
return mz_compressBound(source_len);
}
#endif /*#ifndef MINIZ_NO_DEFLATE_APIS*/

#ifndef MINIZ_NO_INFLATE_APIS
#define inflateInit mz_inflateInit
#define inflateInit2 mz_inflateInit2
#define inflateReset mz_inflateReset
#define inflate mz_inflate
#define inflateEnd mz_inflateEnd
#define uncompress mz_uncompress
#define uncompress2 mz_uncompress2
/* Compatiblity with zlib API. See called functions for documentation */
static int inflateInit(mz_streamp pStream)

Check warning on line 532 in miniz.h

View workflow job for this annotation

GitHub Actions / build

‘inflateInit’ defined but not used [-Wunused-function]
{
return mz_inflateInit(pStream);
}

static int inflateInit2(mz_streamp pStream, int window_bits)

Check warning on line 537 in miniz.h

View workflow job for this annotation

GitHub Actions / build

‘inflateInit2’ defined but not used [-Wunused-function]
{
return mz_inflateInit2(pStream, window_bits);
}

static int inflateReset(mz_streamp pStream)

Check warning on line 542 in miniz.h

View workflow job for this annotation

GitHub Actions / build

‘inflateReset’ defined but not used [-Wunused-function]
{
return mz_inflateReset(pStream);
}

static int inflate(mz_streamp pStream, int flush)

Check warning on line 547 in miniz.h

View workflow job for this annotation

GitHub Actions / build

‘inflate’ defined but not used [-Wunused-function]
{
return mz_inflate(pStream, flush);
}

static int inflateEnd(mz_streamp pStream)

Check warning on line 552 in miniz.h

View workflow job for this annotation

GitHub Actions / build

‘inflateEnd’ defined but not used [-Wunused-function]
{
return mz_inflateEnd(pStream);
}

static int uncompress(unsigned char* pDest, mz_ulong* pDest_len, const unsigned char* pSource, mz_ulong source_len)

Check warning on line 557 in miniz.h

View workflow job for this annotation

GitHub Actions / build

‘uncompress’ defined but not used [-Wunused-function]
{
return mz_uncompress(pDest, pDest_len, pSource, source_len);
}

static int uncompress2(unsigned char* pDest, mz_ulong* pDest_len, const unsigned char* pSource, mz_ulong* pSource_len)

Check warning on line 562 in miniz.h

View workflow job for this annotation

GitHub Actions / build

‘uncompress2’ defined but not used [-Wunused-function]
{
return mz_uncompress2(pDest, pDest_len, pSource, pSource_len);
}
#endif /*#ifndef MINIZ_NO_INFLATE_APIS*/

#define crc32 mz_crc32
#define adler32 mz_adler32
static mz_ulong crc32(mz_ulong crc, const unsigned char *ptr, size_t buf_len)

Check warning on line 568 in miniz.h

View workflow job for this annotation

GitHub Actions / build

‘crc32’ defined but not used [-Wunused-function]
{
return mz_crc32(crc, ptr, buf_len);
}

static mz_ulong adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len)

Check warning on line 573 in miniz.h

View workflow job for this annotation

GitHub Actions / build

‘adler32’ defined but not used [-Wunused-function]
{
return mz_adler32(adler, ptr, buf_len);
}

#define MAX_WBITS 15
#define MAX_MEM_LEVEL 9
#define zError mz_error

static const char* zError(int err)

Check warning on line 581 in miniz.h

View workflow job for this annotation

GitHub Actions / build

‘zError’ defined but not used [-Wunused-function]
{
return mz_error(err);
}
#define ZLIB_VERSION MZ_VERSION
#define ZLIB_VERNUM MZ_VERNUM
#define ZLIB_VER_MAJOR MZ_VER_MAJOR
#define ZLIB_VER_MINOR MZ_VER_MINOR
#define ZLIB_VER_REVISION MZ_VER_REVISION
#define ZLIB_VER_SUBREVISION MZ_VER_SUBREVISION

#define zlibVersion mz_version
#define zlib_version mz_version()
#endif /* #ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES */
Expand All @@ -530,4 +602,4 @@ extern "C"
#include "miniz_common.h"
#include "miniz_tdef.h"
#include "miniz_tinfl.h"
#include "miniz_zip.h"
#include "miniz_zip.h"

0 comments on commit 2fa13ca

Please sign in to comment.