5 #define ZALLOC_ALIGNMENT 16
7 static void *zalloc(void *x
, unsigned items
, unsigned size
)
12 size
= (size
+ ZALLOC_ALIGNMENT
- 1) & ~(ZALLOC_ALIGNMENT
- 1);
19 static void zfree(void *x
, void *addr
, unsigned nb
)
32 int gunzip(void *dst
, int dstlen
, unsigned char *src
, unsigned long *lenp
)
40 if (src
[2] != DEFLATED
|| (flags
& RESERVED
) != 0) {
41 puts ("Error: Bad gzipped data\n");
44 if ((flags
& EXTRA_FIELD
) != 0)
45 i
= 12 + src
[10] + (src
[11] << 8);
46 if ((flags
& ORIG_NAME
) != 0)
49 if ((flags
& COMMENT
) != 0)
52 if ((flags
& HEAD_CRC
) != 0)
55 puts ("Error: gunzip out of data in header\n");
61 #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
62 s
.outcb
= (cb_func
)WATCHDOG_RESET
;
65 #endif /* CONFIG_HW_WATCHDOG */
67 r
= inflateInit2(&s
, -MAX_WBITS
);
69 printf ("Error: inflateInit2() returned %d\n", r
);
73 s
.avail_in
= *lenp
- i
;
76 r
= inflate(&s
, Z_FINISH
);
77 if (r
!= Z_OK
&& r
!= Z_STREAM_END
) {
78 printf ("Error: inflate() returned %d\n", r
);
81 *lenp
= s
.next_out
- (unsigned char *) dst
;