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