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

Function gzfread

freebsd/contrib/zstd/zlibWrapper/gzread.c:423–451  ·  view source on GitHub ↗

-- see zlib.h -- */

(buf, size, nitems, file)

Source from the content-addressed store, hash-verified

421
422/* -- see zlib.h -- */
423z_size_t ZEXPORT gzfread(buf, size, nitems, file)
424 voidp buf;
425 z_size_t size;
426 z_size_t nitems;
427 gzFile file;
428{
429 z_size_t len;
430 gz_statep state;
431
432 /* get internal structure */
433 if (file == NULL)
434 return 0;
435 state.file = file;
436
437 /* check that we're reading and that there's no (serious) error */
438 if (state.state->mode != GZ_READ ||
439 (state.state->err != Z_OK && state.state->err != Z_BUF_ERROR))
440 return 0;
441
442 /* compute bytes to read -- error on overflow */
443 len = nitems * size;
444 if (size && len / size != nitems) {
445 gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t");
446 return 0;
447 }
448
449 /* read len or fewer bytes to buf, return the number of full items read */
450 return len ? gz_read(state, buf, len) / size : 0;
451}
452
453/* -- see zlib.h -- */
454#if ZLIB_VERNUM >= 0x1261

Callers

nothing calls this directly

Calls 2

gz_errorFunction · 0.70
gz_readFunction · 0.70

Tested by

no test coverage detected