MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / gz_zero

Function gz_zero

extlibs/minizip/src/gzwrite.c:162–193  ·  view source on GitHub ↗

Compress len zeros to output. Return -1 on a write error or memory allocation failure by gz_comp(), or 0 on success. */

(state, len)

Source from the content-addressed store, hash-verified

160/* Compress len zeros to output. Return -1 on a write error or memory
161 allocation failure by gz_comp(), or 0 on success. */
162local int gz_zero(state, len)
163gz_statep state;
164z_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. */

Callers 7

gz_writeFunction · 0.85
gzputcFunction · 0.85
gzvprintfFunction · 0.85
ZEXPORTVAFunction · 0.85
gzflushFunction · 0.85
gzsetparamsFunction · 0.85
gzclose_wFunction · 0.85

Calls 1

gz_compFunction · 0.85

Tested by

no test coverage detected