Skip to content

Commit

Permalink
gunzip: rename z{alloc, free} to gz{alloc, free}
Browse files Browse the repository at this point in the history
This allows us to add a proper zalloc() func (one that does a zeroing
alloc), and removes duplicate prototypes.

Signed-off-by: Mike Frysinger <[email protected]>
  • Loading branch information
vapier authored and vdsao committed Apr 30, 2012
1 parent 9a800ac commit e3ed057
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
7 changes: 2 additions & 5 deletions fs/cramfs/uncompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@

static z_stream stream;

void *zalloc(void *, unsigned, unsigned);
void zfree(void *, void *, unsigned);

/* Returns length of decompressed data. */
int cramfs_uncompress_block (void *dst, void *src, int srclen)
{
Expand Down Expand Up @@ -59,8 +56,8 @@ int cramfs_uncompress_init (void)
{
int err;

stream.zalloc = zalloc;
stream.zfree = zfree;
stream.zalloc = gzalloc;
stream.zfree = gzfree;
stream.next_in = 0;
stream.avail_in = 0;

Expand Down
3 changes: 3 additions & 0 deletions include/u-boot/zlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,9 @@ ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
struct internal_state {int dummy;}; /* hack for buggy compilers */
#endif

extern void *gzalloc(void *, unsigned, unsigned);
extern void gzfree(void *, void *, unsigned);

#ifdef __cplusplus
}
#endif
Expand Down
11 changes: 4 additions & 7 deletions lib/gunzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@
#define RESERVED 0xe0
#define DEFLATED 8

void *zalloc(void *, unsigned, unsigned);
void zfree(void *, void *, unsigned);

void *zalloc(void *x, unsigned items, unsigned size)
void *gzalloc(void *x, unsigned items, unsigned size)
{
void *p;

Expand All @@ -51,7 +48,7 @@ void *zalloc(void *x, unsigned items, unsigned size)
return (p);
}

void zfree(void *x, void *addr, unsigned nb)
void gzfree(void *x, void *addr, unsigned nb)
{
free (addr);
}
Expand Down Expand Up @@ -94,8 +91,8 @@ int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp,
z_stream s;
int r;

s.zalloc = zalloc;
s.zfree = zfree;
s.zalloc = gzalloc;
s.zfree = gzfree;

r = inflateInit2(&s, -MAX_WBITS);
if (r != Z_OK) {
Expand Down

0 comments on commit e3ed057

Please sign in to comment.