MCPcopy Create free account
hub / github.com/F-Stack/f-stack / gz_zero

Function gz_zero

freebsd/contrib/zlib/gzwrite.c:148–177  ·  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

146/* Compress len zeros to output. Return -1 on a write error or memory
147 allocation failure by gz_comp(), or 0 on success. */
148local 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. */

Callers 7

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

Calls 2

memsetFunction · 0.85
gz_compFunction · 0.70

Tested by

no test coverage detected