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

Function gzwrite

freebsd/contrib/zstd/zlibWrapper/gzwrite.c:251–276  ·  view source on GitHub ↗

-- see zlib.h -- */

(file, buf, len)

Source from the content-addressed store, hash-verified

249
250/* -- see zlib.h -- */
251int ZEXPORT gzwrite(file, buf, len)
252 gzFile file;
253 voidpc buf;
254 unsigned len;
255{
256 gz_statep state;
257
258 /* get internal structure */
259 if (file == NULL)
260 return 0;
261 state.file = file;
262
263 /* check that we're writing and that there's no error */
264 if (state.state->mode != GZ_WRITE || state.state->err != Z_OK)
265 return 0;
266
267 /* since an int is returned, make sure len fits in one, otherwise return
268 with an error (this avoids a flaw in the interface) */
269 if ((int)len < 0) {
270 gz_error(state, Z_DATA_ERROR, "requested length does not fit in int");
271 return 0;
272 }
273
274 /* write len bytes from buf (the return value will fit in an int) */
275 return (int)gz_write(state, buf, len);
276}
277
278/* -- see zlib.h -- */
279z_size_t ZEXPORT gzfwrite(buf, size, nitems, file)

Callers

nothing calls this directly

Calls 2

gz_errorFunction · 0.70
gz_writeFunction · 0.70

Tested by

no test coverage detected