MCPcopy Create free account
hub / github.com/9chu/LuaSTGPlus / gz_zero

Function gz_zero

ZLib/gzwrite.c:133–162  ·  view source on GitHub ↗

Compress len zeros to output. Return -1 on error, 0 on success. */

(state, len)

Source from the content-addressed store, hash-verified

131
132/* Compress len zeros to output. Return -1 on error, 0 on success. */
133local int gz_zero(state, len)
134 gz_statep state;
135 z_off64_t len;
136{
137 int first;
138 unsigned n;
139 z_streamp strm = &(state->strm);
140
141 /* consume whatever's left in the input buffer */
142 if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
143 return -1;
144
145 /* compress len zeros (len guaranteed > 0) */
146 first = 1;
147 while (len) {
148 n = GT_OFF(state->size) || (z_off64_t)state->size > len ?
149 (unsigned)len : state->size;
150 if (first) {
151 memset(state->in, 0, n);
152 first = 0;
153 }
154 strm->avail_in = n;
155 strm->next_in = state->in;
156 state->x.pos += n;
157 if (gz_comp(state, Z_NO_FLUSH) == -1)
158 return -1;
159 len -= n;
160 }
161 return 0;
162}
163
164/* -- see zlib.h -- */
165int ZEXPORT gzwrite(file, buf, len)

Callers 7

gzwriteFunction · 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