diff options
author | marha <marha@users.sourceforge.net> | 2013-11-12 13:48:44 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2013-11-12 13:51:05 +0100 |
commit | 4bdf8409331f44417c3622bc5ec0e42c0e68afb6 (patch) | |
tree | ee8a24a92b267f48542eaed1968266a76e945a27 /zlib/examples/gzappend.c | |
parent | b73c544c61712f7bd57f3c9a0f6046481f58038b (diff) | |
download | vcxsrv-4bdf8409331f44417c3622bc5ec0e42c0e68afb6.tar.gz vcxsrv-4bdf8409331f44417c3622bc5ec0e42c0e68afb6.tar.bz2 vcxsrv-4bdf8409331f44417c3622bc5ec0e42c0e68afb6.zip |
Updated zlib to 1.2.8
Diffstat (limited to 'zlib/examples/gzappend.c')
-rw-r--r-- | zlib/examples/gzappend.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/zlib/examples/gzappend.c b/zlib/examples/gzappend.c index e9e878e11..662dec379 100644 --- a/zlib/examples/gzappend.c +++ b/zlib/examples/gzappend.c @@ -1,7 +1,7 @@ /* gzappend -- command to append to a gzip file - Copyright (C) 2003 Mark Adler, all rights reserved - version 1.1, 4 Nov 2003 + Copyright (C) 2003, 2012 Mark Adler, all rights reserved + version 1.2, 11 Oct 2012 This software is provided 'as-is', without any express or implied warranty. In no event will the author be held liable for any damages @@ -39,6 +39,8 @@ * - Keep gzip file clean on appended file read errors * - Use in-place rotate instead of auxiliary buffer * (Why you ask? Because it was fun to write!) + * 1.2 11 Oct 2012 - Fix for proper z_const usage + * - Check for input buffer malloc failure */ /* @@ -170,7 +172,7 @@ typedef struct { int size; /* 1 << size is bytes in buf */ unsigned left; /* bytes available at next */ unsigned char *buf; /* buffer */ - unsigned char *next; /* next byte in buffer */ + z_const unsigned char *next; /* next byte in buffer */ char *name; /* file name for error messages */ } file; @@ -399,14 +401,14 @@ local void gztack(char *name, int gd, z_stream *strm, int last) } /* allocate buffers */ - in = fd == -1 ? NULL : malloc(CHUNK); + in = malloc(CHUNK); out = malloc(CHUNK); - if (out == NULL) bye("out of memory", ""); + if (in == NULL || out == NULL) bye("out of memory", ""); /* compress input file and append to gzip file */ do { /* get more input */ - len = fd == -1 ? 0 : read(fd, in, CHUNK); + len = read(fd, in, CHUNK); if (len == -1) { fprintf(stderr, "gzappend warning: error reading %s, skipping rest ...\n", @@ -453,7 +455,7 @@ local void gztack(char *name, int gd, z_stream *strm, int last) /* clean up and return */ free(out); - if (in != NULL) free(in); + free(in); if (fd > 0) close(fd); } @@ -467,11 +469,13 @@ int main(int argc, char **argv) z_stream strm; /* ignore command name */ - argv++; + argc--; argv++; /* provide usage if no arguments */ if (*argv == NULL) { - printf("gzappend 1.1 (4 Nov 2003) Copyright (C) 2003 Mark Adler\n"); + printf( + "gzappend 1.2 (11 Oct 2012) Copyright (C) 2003, 2012 Mark Adler\n" + ); printf( "usage: gzappend [-level] file.gz [ addthis [ andthis ... ]]\n"); return 0; |