MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / gz_zero

Function gz_zero

extern/zlib/src/gzwrite.c:143–169  ·  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. */

Source from the content-addressed store, hash-verified

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

Callers 7

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

Calls 1

gz_compFunction · 0.85

Tested by

no test coverage detected