Compress len zeros to output. Return -1 on a write error or memory allocation failure by gz_comp(), or 0 on success. */
(state, len)
| 146 | /* Compress len zeros to output. Return -1 on a write error or memory |
| 147 | allocation failure by gz_comp(), or 0 on success. */ |
| 148 | local int gz_zero(state, len) |
| 149 | gz_statep state; |
| 150 | z_off64_t len; |
| 151 | { |
| 152 | int first; |
| 153 | unsigned n; |
| 154 | z_streamp strm = &(state->strm); |
| 155 | |
| 156 | /* consume whatever's left in the input buffer */ |
| 157 | if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1) |
| 158 | return -1; |
| 159 | |
| 160 | /* compress len zeros (len guaranteed > 0) */ |
| 161 | first = 1; |
| 162 | while (len) { |
| 163 | n = GT_OFF(state->size) || (z_off64_t)state->size > len ? |
| 164 | (unsigned)len : state->size; |
| 165 | if (first) { |
| 166 | memset(state->in, 0, n); |
| 167 | first = 0; |
| 168 | } |
| 169 | strm->avail_in = n; |
| 170 | strm->next_in = state->in; |
| 171 | state->x.pos += n; |
| 172 | if (gz_comp(state, Z_NO_FLUSH) == -1) |
| 173 | return -1; |
| 174 | len -= n; |
| 175 | } |
| 176 | return 0; |
| 177 | } |
| 178 | |
| 179 | /* Write len bytes from buf to file. Return the number of bytes written. If |
| 180 | the returned value is less than len, then there was an error. */ |