2011-04-08 12:23:30 +00:00
|
|
|
/* zutil.c -- target dependent utility functions for the compression library
|
|
|
|
* Copyright (C) 1995-2005 Jean-loup Gailly.
|
|
|
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* @(#) $Id$ */
|
|
|
|
|
|
|
|
#include "zutil.h"
|
2019-12-28 17:45:07 +00:00
|
|
|
#include <hang.h>
|
2011-04-08 12:23:30 +00:00
|
|
|
|
|
|
|
#ifndef NO_DUMMY_DECL
|
|
|
|
struct internal_state {int dummy;}; /* for buggy compilers */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
const char * const z_errmsg[10] = {
|
|
|
|
"need dictionary", /* Z_NEED_DICT 2 */
|
|
|
|
"stream end", /* Z_STREAM_END 1 */
|
|
|
|
"", /* Z_OK 0 */
|
|
|
|
"file error", /* Z_ERRNO (-1) */
|
|
|
|
"stream error", /* Z_STREAM_ERROR (-2) */
|
|
|
|
"data error", /* Z_DATA_ERROR (-3) */
|
|
|
|
"insufficient memory", /* Z_MEM_ERROR (-4) */
|
|
|
|
"buffer error", /* Z_BUF_ERROR (-5) */
|
|
|
|
"incompatible version",/* Z_VERSION_ERROR (-6) */
|
|
|
|
""};
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
|
|
|
#ifndef verbose
|
|
|
|
#define verbose 0
|
|
|
|
#endif
|
|
|
|
int z_verbose = verbose;
|
|
|
|
|
|
|
|
void z_error (m)
|
|
|
|
char *m;
|
|
|
|
{
|
|
|
|
fprintf(stderr, "%s\n", m);
|
2019-12-28 17:45:07 +00:00
|
|
|
hang();
|
2011-04-08 12:23:30 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* exported to allow conversion of error code to string for compress() and
|
|
|
|
* uncompress()
|
|
|
|
*/
|
|
|
|
#ifndef MY_ZCALLOC /* Any system without a special alloc function */
|
|
|
|
|
2015-09-02 23:24:57 +00:00
|
|
|
#ifdef __UBOOT__
|
|
|
|
#include <malloc.h>
|
|
|
|
#else
|
2011-04-08 12:23:30 +00:00
|
|
|
#ifndef STDC
|
|
|
|
extern voidp malloc OF((uInt size));
|
|
|
|
extern voidp calloc OF((uInt items, uInt size));
|
|
|
|
extern void free OF((voidpf ptr));
|
|
|
|
#endif
|
2015-08-18 11:06:37 +00:00
|
|
|
#endif
|
2011-04-08 12:23:30 +00:00
|
|
|
|
2012-10-29 13:34:35 +00:00
|
|
|
voidpf zcalloc(voidpf opaque, unsigned items, unsigned size)
|
2011-04-08 12:23:30 +00:00
|
|
|
{
|
|
|
|
if (opaque)
|
|
|
|
items += size - size; /* make compiler happy */
|
|
|
|
return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
|
|
|
|
(voidpf)calloc(items, size);
|
|
|
|
}
|
|
|
|
|
2012-10-29 13:34:35 +00:00
|
|
|
void zcfree(voidpf opaque, voidpf ptr, unsigned nb)
|
2011-04-08 12:23:30 +00:00
|
|
|
{
|
|
|
|
free(ptr);
|
|
|
|
if (opaque)
|
|
|
|
return; /* make compiler happy */
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* MY_ZCALLOC */
|