File: zlib-2.c

package info (click to toggle)
gcc-arm-none-eabi 15%3A12.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 959,712 kB
  • sloc: cpp: 3,275,382; ansic: 2,061,766; ada: 840,956; f90: 208,513; makefile: 76,132; asm: 73,433; xml: 50,448; exp: 34,146; sh: 32,436; objc: 15,637; fortran: 14,012; python: 11,991; pascal: 6,787; awk: 4,779; perl: 3,054; yacc: 338; ml: 285; lex: 201; haskell: 122
file content (49 lines) | stat: -rw-r--r-- 1,254 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
typedef void * (*alloc_func)(void * opaque, unsigned items, unsigned size);
typedef void (*free_func)(void * opaque, void * address);

typedef struct z_stream_s {
  char *msg;
  alloc_func zalloc;
  free_func zfree;
  void * opaque;
} z_stream;

void * zcalloc(void * opaque, unsigned items, unsigned size);
void zcfree(void * opaque, void * ptr);

int deflateInit2_(z_stream *strm, int level, int method, int windowBits,
                  int memLevel, int strategy, const char *version,
                  int stream_size) {
  int noheader = 0;
  static const char *my_version = "1.1.3";

  if (version == 0 || version[0] != my_version[0] ||
      stream_size != sizeof(z_stream)) {
    return (-6);
  }
  if (strm == 0)
    return (-2);

  strm->msg = 0;
  if (strm->zalloc == 0) {
    strm->zalloc = zcalloc;
    strm->opaque = (void *)0;
  }
  if (strm->zfree == 0)
    strm->zfree = zcfree;

  if (level == (-1))
    level = 6;

  if (windowBits < 0) {
    noheader = 1;
    windowBits = -windowBits;
  }
  if (memLevel < 1 || memLevel > 9 || method != 8 || windowBits < 8 ||
      windowBits > 15 || level < 0 || level > 9 || strategy < 0 ||
      strategy > 2) {
    return (-2);
  }
  (*((strm)->zalloc))((strm)->opaque, (1), 112);
  return 0;
}