Compress len zeros to output. Return -1 on a write error or memory allocation failure by gz_comp(), or 0 on success. */
(state, len)
| 160 | /* Compress len zeros to output. Return -1 on a write error or memory |
| 161 | allocation failure by gz_comp(), or 0 on success. */ |
| 162 | local int gz_zero(state, len) |
| 163 | gz_statep state; |
| 164 | z_off64_t len; |
| 165 | { |
| 166 | int first; |
| 167 | unsigned n; |
| 168 | z_streamp strm = &(state->strm); |
| 169 | |
| 170 | /* consume whatever's left in the input buffer */ |
| 171 | if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1) |
| 172 | return -1; |
| 173 | |
| 174 | /* compress len zeros (len guaranteed > 0) */ |
| 175 | first = 1; |
| 176 | while (len) |
| 177 | { |
| 178 | n = GT_OFF(state->size) || (z_off64_t)state->size > len ? |
| 179 | (unsigned)len : state->size; |
| 180 | if (first) |
| 181 | { |
| 182 | memset(state->in, 0, n); |
| 183 | first = 0; |
| 184 | } |
| 185 | strm->avail_in = n; |
| 186 | strm->next_in = state->in; |
| 187 | state->x.pos += n; |
| 188 | if (gz_comp(state, Z_NO_FLUSH) == -1) |
| 189 | return -1; |
| 190 | len -= n; |
| 191 | } |
| 192 | return 0; |
| 193 | } |
| 194 | |
| 195 | /* Write len bytes from buf to file. Return the number of bytes written. If |
| 196 | the returned value is less than len, then there was an error. */ |