Rizin
unix-like reverse engineering framework and cli tools
zutil.c File Reference
#include "zutil.h"
#include "gzguts.h"

Go to the source code of this file.

Functions

const char *ZEXPORT zlibVersion ()
 
uLong ZEXPORT zlibCompileFlags ()
 
const char *ZEXPORT zError (int err)
 
void ZLIB_INTERNAL zmemcpy (Bytef *dest, const Bytef *source, uInt len)
 
int ZLIB_INTERNAL zmemcmp (Bytef *s1, const Bytef *s2, uInt len) const
 
void ZLIB_INTERNAL zmemzero (Bytef *dest, uInt len)
 
voidp malloc OF ((uInt size))
 
voidp calloc OF ((uInt items, uInt size))
 
void free OF ((voidpf ptr))
 
voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size)
 
void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
 

Variables

z_const char *const z_errmsg [10]
 

Function Documentation

◆ OF() [1/3]

voidp calloc OF ( (uInt items, uInt size )

◆ OF() [2/3]

voidp malloc OF ( (uInt size )

◆ OF() [3/3]

void free OF ( (voidpf ptr)  )

◆ zcalloc()

voidpf ZLIB_INTERNAL zcalloc ( voidpf  opaque,
unsigned  items,
unsigned  size 
)

Definition at line 305 of file zutil.c.

309 {
310  (void)opaque;
311  return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
312  (voidpf)calloc(items, size);
313 }
voidpf void uLong size
Definition: ioapi.h:138
void * malloc(size_t size)
Definition: malloc.c:123
void * calloc(size_t number, size_t size)
Definition: malloc.c:102
Byte FAR * voidpf
Definition: zconf.h:413
unsigned int uInt
Definition: zconf.h:393

References calloc(), and malloc().

Referenced by clusterSendPing(), deflateInit2_(), inflateBack9Init_(), inflateBackInit_(), and inflateInit2_().

◆ zcfree()

void ZLIB_INTERNAL zcfree ( voidpf  opaque,
voidpf  ptr 
)

Definition at line 315 of file zutil.c.

318 {
319  (void)opaque;
320  free(ptr);
321 }
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130

References free().

Referenced by deflateInit2_(), inflateBack9Init_(), inflateBackInit_(), and inflateInit2_().

◆ zError()

const char* ZEXPORT zError ( int  err)

Definition at line 133 of file zutil.c.

135 {
136  return ERR_MSG(err);
137 }
static bool err
Definition: armass.c:435
#define ERR_MSG(err)
Definition: zutil.h:59

References err, and ERR_MSG.

Referenced by zip_error_strerror(), and zip_error_to_str().

◆ zlibCompileFlags()

uLong ZEXPORT zlibCompileFlags ( )

Definition at line 32 of file zutil.c.

33 {
34  uLong flags;
35 
36  flags = 0;
37  switch ((int)(sizeof(uInt))) {
38  case 2: break;
39  case 4: flags += 1; break;
40  case 8: flags += 2; break;
41  default: flags += 3;
42  }
43  switch ((int)(sizeof(uLong))) {
44  case 2: break;
45  case 4: flags += 1 << 2; break;
46  case 8: flags += 2 << 2; break;
47  default: flags += 3 << 2;
48  }
49  switch ((int)(sizeof(voidpf))) {
50  case 2: break;
51  case 4: flags += 1 << 4; break;
52  case 8: flags += 2 << 4; break;
53  default: flags += 3 << 4;
54  }
55  switch ((int)(sizeof(z_off_t))) {
56  case 2: break;
57  case 4: flags += 1 << 6; break;
58  case 8: flags += 2 << 6; break;
59  default: flags += 3 << 6;
60  }
61 #ifdef ZLIB_DEBUG
62  flags += 1 << 8;
63 #endif
64 #if defined(ASMV) || defined(ASMINF)
65  flags += 1 << 9;
66 #endif
67 #ifdef ZLIB_WINAPI
68  flags += 1 << 10;
69 #endif
70 #ifdef BUILDFIXED
71  flags += 1 << 12;
72 #endif
73 #ifdef DYNAMIC_CRC_TABLE
74  flags += 1 << 13;
75 #endif
76 #ifdef NO_GZCOMPRESS
77  flags += 1L << 16;
78 #endif
79 #ifdef NO_GZIP
80  flags += 1L << 17;
81 #endif
82 #ifdef PKZIP_BUG_WORKAROUND
83  flags += 1L << 20;
84 #endif
85 #ifdef FASTEST
86  flags += 1L << 21;
87 #endif
88 #if defined(STDC) || defined(Z_HAVE_STDARG_H)
89 # ifdef NO_vsnprintf
90  flags += 1L << 25;
91 # ifdef HAS_vsprintf_void
92  flags += 1L << 26;
93 # endif
94 # else
95 # ifdef HAS_vsnprintf_void
96  flags += 1L << 26;
97 # endif
98 # endif
99 #else
100  flags += 1L << 24;
101 # ifdef NO_snprintf
102  flags += 1L << 25;
103 # ifdef HAS_sprintf_void
104  flags += 1L << 26;
105 # endif
106 # else
107 # ifdef HAS_snprintf_void
108  flags += 1L << 26;
109 # endif
110 # endif
111 #endif
112  return flags;
113 }
static struct sockaddr static addrlen static backlog const void static flags void flags
Definition: sfsocketcall.h:123
unsigned long uLong
Definition: zconf.h:394
#define z_off_t
Definition: zconf.h:504

References flags, and z_off_t.

◆ zlibVersion()

const char* ZEXPORT zlibVersion ( )

Definition at line 27 of file zutil.c.

28 {
29  return ZLIB_VERSION;
30 }
#define ZLIB_VERSION
Definition: zlib.h:40

References ZLIB_VERSION.

Referenced by help().

◆ zmemcmp()

int ZLIB_INTERNAL zmemcmp ( Bytef s1,
const Bytef s2,
uInt  len 
) const

Definition at line 160 of file zutil.c.

164 {
165  uInt j;
166 
167  for (j = 0; j < len; j++) {
168  if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;
169  }
170  return 0;
171 }
size_t len
Definition: 6502dis.c:15
#define s1(x)
Definition: sha256.c:60

References len, s1, and s2.

◆ zmemcpy()

void ZLIB_INTERNAL zmemcpy ( Bytef dest,
const Bytef source,
uInt  len 
)

Definition at line 149 of file zutil.c.

153 {
154  if (len == 0) return;
155  do {
156  *dest++ = *source++; /* ??? to be unrolled */
157  } while (--len != 0);
158 }
const char * source
Definition: lz4.h:699
char * dest
Definition: lz4.h:697

References dest, len, and source.

Referenced by _tr_stored_block(), deflate(), deflate_stored(), deflateCopy(), deflateGetDictionary(), fill_window(), flush_pending(), inflate(), inflateBack(), inflateBack9(), inflateCopy(), inflateGetDictionary(), read_buf(), and updatewindow().

◆ zmemzero()

void ZLIB_INTERNAL zmemzero ( Bytef dest,
uInt  len 
)

Definition at line 173 of file zutil.c.

176 {
177  if (len == 0) return;
178  do {
179  *dest++ = 0; /* ??? to be unrolled */
180  } while (--len != 0);
181 }

References dest, and len.

Referenced by fill_window().

Variable Documentation

◆ z_errmsg

z_const char* const z_errmsg[10]
Initial value:
= {
(z_const char *)"need dictionary",
(z_const char *)"stream end",
(z_const char *)"",
(z_const char *)"file error",
(z_const char *)"stream error",
(z_const char *)"data error",
(z_const char *)"insufficient memory",
(z_const char *)"buffer error",
(z_const char *)"incompatible version",
(z_const char *)""
}
#define z_const
Definition: zconf.h:237

Definition at line 13 of file zutil.c.