diff options
author | Mark Adler <madler@alumni.caltech.edu> | 2011-09-09 23:24:52 -0700 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2011-09-09 23:24:52 -0700 |
commit | 9c3a5830218c4e7fff23b8fc4386269db77a03a9 (patch) | |
tree | 913542049433ae44de55d22913f6bca921f2dc15 /examples/fitblk.c | |
parent | 6b8233bfe00e79134cb1b84fc49d4f750a797f79 (diff) | |
download | zlib-1.2.2.4.tar.gz zlib-1.2.2.4.tar.bz2 zlib-1.2.2.4.zip |
zlib 1.2.2.4v1.2.2.4
Diffstat (limited to 'examples/fitblk.c')
-rw-r--r-- | examples/fitblk.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/examples/fitblk.c b/examples/fitblk.c index 5f83114..c61de5c 100644 --- a/examples/fitblk.c +++ b/examples/fitblk.c | |||
@@ -73,7 +73,7 @@ local void quit(char *why) | |||
73 | local int partcompress(FILE *in, z_streamp def) | 73 | local int partcompress(FILE *in, z_streamp def) |
74 | { | 74 | { |
75 | int ret, flush; | 75 | int ret, flush; |
76 | char raw[RAWLEN]; | 76 | unsigned char raw[RAWLEN]; |
77 | 77 | ||
78 | flush = Z_NO_FLUSH; | 78 | flush = Z_NO_FLUSH; |
79 | do { | 79 | do { |
@@ -96,7 +96,7 @@ local int partcompress(FILE *in, z_streamp def) | |||
96 | local int recompress(z_streamp inf, z_streamp def) | 96 | local int recompress(z_streamp inf, z_streamp def) |
97 | { | 97 | { |
98 | int ret, flush; | 98 | int ret, flush; |
99 | char raw[RAWLEN]; | 99 | unsigned char raw[RAWLEN]; |
100 | 100 | ||
101 | flush = Z_NO_FLUSH; | 101 | flush = Z_NO_FLUSH; |
102 | do { | 102 | do { |
@@ -129,8 +129,8 @@ int main(int argc, char **argv) | |||
129 | int ret; /* return code */ | 129 | int ret; /* return code */ |
130 | unsigned size; /* requested fixed output block size */ | 130 | unsigned size; /* requested fixed output block size */ |
131 | unsigned have; /* bytes written by deflate() call */ | 131 | unsigned have; /* bytes written by deflate() call */ |
132 | char *blk; /* intermediate and final stream */ | 132 | unsigned char *blk; /* intermediate and final stream */ |
133 | char *tmp; /* close to desired size stream */ | 133 | unsigned char *tmp; /* close to desired size stream */ |
134 | z_stream def, inf; /* zlib deflate and inflate states */ | 134 | z_stream def, inf; /* zlib deflate and inflate states */ |
135 | 135 | ||
136 | /* get requested output size */ | 136 | /* get requested output size */ |
@@ -163,8 +163,7 @@ int main(int argc, char **argv) | |||
163 | if (ret == Z_STREAM_END && def.avail_out >= EXCESS) { | 163 | if (ret == Z_STREAM_END && def.avail_out >= EXCESS) { |
164 | /* write block to stdout */ | 164 | /* write block to stdout */ |
165 | have = size + EXCESS - def.avail_out; | 165 | have = size + EXCESS - def.avail_out; |
166 | ret = fwrite(blk, 1, have, stdout); | 166 | if (fwrite(blk, 1, have, stdout) != have || ferror(stdout)) |
167 | if (ret != have || ferror(stdout)) | ||
168 | quit("error writing output"); | 167 | quit("error writing output"); |
169 | 168 | ||
170 | /* clean up and print results to stderr */ | 169 | /* clean up and print results to stderr */ |
@@ -217,8 +216,7 @@ int main(int argc, char **argv) | |||
217 | 216 | ||
218 | /* done -- write block to stdout */ | 217 | /* done -- write block to stdout */ |
219 | have = size - def.avail_out; | 218 | have = size - def.avail_out; |
220 | ret = fwrite(blk, 1, have, stdout); | 219 | if (fwrite(blk, 1, have, stdout) != have || ferror(stdout)) |
221 | if (ret != have || ferror(stdout)) | ||
222 | quit("error writing output"); | 220 | quit("error writing output"); |
223 | 221 | ||
224 | /* clean up and print results to stderr */ | 222 | /* clean up and print results to stderr */ |