This source file includes following definitions.
- zlibVersion
- zlibCompileFlags
- z_error
- zError
- zmemcpy
- zmemcmp
- zmemzero
- zcalloc
- zcgf_free
- zcalloc
- zcgf_free
- zcalloc
- zcgf_free
#include "zutil.h"
#include <gpac/setup.h>
#ifndef NO_DUMMY_DECL
struct internal_state {
int dummy;
};
#endif
const char * const z_errmsg[10] = {
"need dictionary",
"stream end",
"",
"file error",
"stream error",
"data error",
"insufficient memory",
"buffer error",
"incompatible version",
""
};
const char * ZEXPORT zlibVersion()
{
return ZLIB_VERSION;
}
uLong ZEXPORT zlibCompileFlags()
{
uLong flags;
flags = 0;
switch (sizeof(uInt)) {
case 2:
break;
case 4:
flags += 1;
break;
case 8:
flags += 2;
break;
default:
flags += 3;
}
switch (sizeof(uLong)) {
case 2:
break;
case 4:
flags += 1 << 2;
break;
case 8:
flags += 2 << 2;
break;
default:
flags += 3 << 2;
}
switch (sizeof(voidpf)) {
case 2:
break;
case 4:
flags += 1 << 4;
break;
case 8:
flags += 2 << 4;
break;
default:
flags += 3 << 4;
}
switch (sizeof(z_off_t)) {
case 2:
break;
case 4:
flags += 1 << 6;
break;
case 8:
flags += 2 << 6;
break;
default:
flags += 3 << 6;
}
#ifdef DEBUG
flags += 1 << 8;
#endif
#if defined(ASMV) || defined(ASMINF)
flags += 1 << 9;
#endif
#ifdef ZLIB_WINAPI
flags += 1 << 10;
#endif
#ifdef BUILDFIXED
flags += 1 << 12;
#endif
#ifdef DYNAMIC_CRC_TABLE
flags += 1 << 13;
#endif
#ifdef NO_GZCOMPRESS
flags += 1L << 16;
#endif
#ifdef NO_GZIP
flags += 1L << 17;
#endif
#ifdef PKZIP_BUG_WORKAROUND
flags += 1L << 20;
#endif
#ifdef FASTEST
flags += 1L << 21;
#endif
#ifdef STDC
# ifdef NO_vsnprintf
flags += 1L << 25;
# ifdef HAS_vsprintf_void
flags += 1L << 26;
# endif
# else
# ifdef HAS_vsnprintf_void
flags += 1L << 26;
# endif
# endif
#else
flags += 1L << 24;
# ifdef NO_snprintf
flags += 1L << 25;
# ifdef HAS_sprintf_void
flags += 1L << 26;
# endif
# else
# ifdef HAS_snprintf_void
flags += 1L << 26;
# endif
# endif
#endif
return flags;
}
#ifdef DEBUG
# ifndef verbose
# define verbose 0
# endif
int z_verbose = verbose;
void z_error (m)
char *m;
{
fprintf(stderr, "%s\n", m);
exit(1);
}
#endif
const char * ZEXPORT zError(err)
int err;
{
return ERR_MSG(err);
}
#if defined(_WIN32_WCE)
int errno = 0;
#endif
#ifndef HAVE_MEMCPY
void zmemcpy(dest, source, len)
Bytef* dest;
const Bytef* source;
uInt len;
{
if (len == 0) return;
do {
*dest++ = *source++;
} while (--len != 0);
}
int zmemcmp(s1, s2, len)
const Bytef* s1;
const Bytef* s2;
uInt len;
{
uInt j;
for (j = 0; j < len; j++) {
if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;
}
return 0;
}
void zmemzero(dest, len)
Bytef* dest;
uInt len;
{
if (len == 0) return;
do {
*dest++ = 0;
} while (--len != 0);
}
#endif
#ifdef SYS16BIT
#ifdef __TURBOC__
# define MY_ZCALLOC
#define MAX_PTR 10
local int next_ptr = 0;
typedef struct ptr_table_s {
voidpf org_ptr;
voidpf new_ptr;
} ptr_table;
local ptr_table table[MAX_PTR];
voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
{
voidpf buf = opaque;
ulg bsize = (ulg)items*size;
if (bsize < 65520L) {
buf = farmalloc(bsize);
if (*(ush*)&buf != 0) return buf;
} else {
buf = farmalloc(bsize + 16L);
}
if (buf == NULL || next_ptr >= MAX_PTR) return NULL;
table[next_ptr].org_ptr = buf;
*((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4;
*(ush*)&buf = 0;
table[next_ptr++].new_ptr = buf;
return buf;
}
void zcgf_free(voidpf opaque, voidpf ptr)
{
int n;
if (*(ush*)&ptr != 0) {
fargf_free(ptr);
return;
}
for (n = 0; n < next_ptr; n++) {
if (ptr != table[n].new_ptr) continue;
fargf_free(table[n].org_ptr);
while (++n < next_ptr) {
table[n-1] = table[n];
}
next_ptr--;
return;
}
ptr = opaque;
Assert(0, "zcfree: ptr not found");
}
#endif
#ifdef M_I86
# define MY_ZCALLOC
#if (!defined(_MSC_VER) || (_MSC_VER <= 600))
# define _halloc halloc
# define _hfree hfree
#endif
voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
{
if (opaque) opaque = 0;
return _halloc((long)items, size);
}
void zcgf_free(voidpf opaque, voidpf ptr)
{
if (opaque) opaque = 0;
_hgf_free(ptr);
}
#endif
#endif
#ifndef MY_ZCALLOC
#ifndef STDC
extern voidp gf_malloc OF((uInt size));
extern voidp gf_calloc OF((uInt items, uInt size));
extern void free OF((voidpf ptr));
#endif
voidpf zcalloc (opaque, items, size)
voidpf opaque;
unsigned items;
unsigned size;
{
if (opaque) items += size - size;
return sizeof(uInt) > 2 ? (voidpf)gf_malloc(items * size) :
(voidpf)gf_calloc(items, size);
}
void zcgf_free(opaque, ptr)
voidpf opaque;
voidpf ptr;
{
gf_free(ptr);
if (opaque) return;
}
#endif