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

Function gzfwrite

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

-- see zlib.h -- */

(buf, size, nitems, file)

Source from the content-addressed store, hash-verified

277
278/* -- see zlib.h -- */
279z_size_t ZEXPORT gzfwrite(buf, size, nitems, file)
280 voidpc buf;
281 z_size_t size;
282 z_size_t nitems;
283 gzFile file;
284{
285 z_size_t len;
286 gz_statep state;
287
288 /* get internal structure */
289 assert(size != 0);
290 if (file == NULL)
291 return 0;
292 state.file = file;
293
294 /* check that we're writing and that there's no error */
295 if (state.state->mode != GZ_WRITE || state.state->err != Z_OK)
296 return 0;
297
298 /* compute bytes to read -- error on overflow */
299 len = nitems * size;
300 if (size && (len / size != nitems)) {
301 gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t");
302 return 0;
303 }
304
305 /* write len bytes to buf, return the number of full items written */
306 return len ? gz_write(state, buf, len) / size : 0;
307}
308
309/* -- see zlib.h -- */
310int ZEXPORT gzputc(file, c)

Callers

nothing calls this directly

Calls 2

gz_errorFunction · 0.70
gz_writeFunction · 0.70

Tested by

no test coverage detected