MCPcopy Create free account
hub / github.com/MariaDB/server / gz_zero

Function gz_zero

zlib/gzwrite.c:154–182  ·  view source on GitHub ↗

Compress state->skip (> 0) zeros to output. Return -1 on a write error or memory allocation failure by gz_comp(), or 0 on success. state->skip is updated with the number of successfully written zeros, in case there is a stall on a non-blocking write destination. */

Source from the content-addressed store, hash-verified

152 updated with the number of successfully written zeros, in case there is a
153 stall on a non-blocking write destination. */
154local int gz_zero(gz_statep state) {
155 int first, ret;
156 unsigned n;
157 z_streamp strm = &(state->strm);
158
159 /* consume whatever's left in the input buffer */
160 if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
161 return -1;
162
163 /* compress state->skip zeros */
164 first = 1;
165 do {
166 n = GT_OFF(state->size) || (z_off64_t)state->size > state->skip ?
167 (unsigned)state->skip : state->size;
168 if (first) {
169 memset(state->in, 0, n);
170 first = 0;
171 }
172 strm->avail_in = n;
173 strm->next_in = state->in;
174 ret = gz_comp(state, Z_NO_FLUSH);
175 n -= strm->avail_in;
176 state->x.pos += n;
177 state->skip -= n;
178 if (ret == -1)
179 return -1;
180 } while (state->skip);
181 return 0;
182}
183
184/* Write len bytes from buf to file. Return the number of bytes written. If
185 the returned value is less than len, then there was an error. If the 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