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

Function gz_zero

freebsd/contrib/zstd/zlibWrapper/gzwrite.c:150–179  ·  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

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