lib/decompress_inflate.c
Source file repositories/reference/linux-study-clean/lib/decompress_inflate.c
File Facts
- System
- Linux kernel
- Corpus path
lib/decompress_inflate.c- Extension
.c- Size
- 4873 bytes
- Lines
- 220
- Domain
- Kernel Services
- Bucket
- lib
- Inferred role
- Kernel Services: implementation source
- Status
- source implementation candidate
Why This File Exists
Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
zlib_inflate/inftrees.czlib_inflate/inffast.czlib_inflate/inflate.czlib_dfltcc/dfltcc.czlib_dfltcc/dfltcc_inflate.clinux/zutil.hzlib_inflate/inftrees.hzlib_inflate/inffast.hzlib_inflate/inflate.hzlib_inflate/infutil.hlinux/decompress/inflate.hlinux/decompress/mm.h
Detected Declarations
function nofillfunction __gunzipfunction gunzipfunction __decompress
Annotated Snippet
void(*error)(char *x)) {
u8 *zbuf;
struct z_stream_s *strm;
int rc;
rc = -1;
if (flush) {
out_len = 0x8000; /* 32 K */
out_buf = malloc(out_len);
} else {
if (!out_len)
out_len = ((size_t)~0) - (size_t)out_buf; /* no limit */
}
if (!out_buf) {
error("Out of memory while allocating output buffer");
goto gunzip_nomem1;
}
if (buf)
zbuf = buf;
else {
zbuf = malloc(GZIP_IOBUF_SIZE);
len = 0;
}
if (!zbuf) {
error("Out of memory while allocating input buffer");
goto gunzip_nomem2;
}
strm = malloc(sizeof(*strm));
if (strm == NULL) {
error("Out of memory while allocating z_stream");
goto gunzip_nomem3;
}
strm->workspace = malloc(flush ? zlib_inflate_workspacesize() :
#ifdef CONFIG_ZLIB_DFLTCC
/* Always allocate the full workspace for DFLTCC */
zlib_inflate_workspacesize());
#else
sizeof(struct inflate_state));
#endif
if (strm->workspace == NULL) {
error("Out of memory while allocating workspace");
goto gunzip_nomem4;
}
if (!fill)
fill = nofill;
if (len == 0)
len = fill(zbuf, GZIP_IOBUF_SIZE);
/* verify the gzip header */
if (len < 10 ||
zbuf[0] != 0x1f || zbuf[1] != 0x8b || zbuf[2] != 0x08) {
if (pos)
*pos = 0;
error("Not a gzip file");
goto gunzip_5;
}
/* skip over gzip header (1f,8b,08... 10 bytes total +
* possible asciz filename)
*/
strm->next_in = zbuf + 10;
strm->avail_in = len - 10;
/* skip over asciz filename */
if (zbuf[3] & 0x8) {
do {
/*
* If the filename doesn't fit into the buffer,
* the file is very probably corrupt. Don't try
* to read more data.
*/
if (strm->avail_in == 0) {
error("header error");
goto gunzip_5;
}
--strm->avail_in;
} while (*strm->next_in++);
}
strm->next_out = out_buf;
strm->avail_out = out_len;
rc = zlib_inflateInit2(strm, -MAX_WBITS);
#ifdef CONFIG_ZLIB_DFLTCC
/* Always keep the window for DFLTCC */
Annotation
- Immediate include surface: `zlib_inflate/inftrees.c`, `zlib_inflate/inffast.c`, `zlib_inflate/inflate.c`, `zlib_dfltcc/dfltcc.c`, `zlib_dfltcc/dfltcc_inflate.c`, `linux/zutil.h`, `zlib_inflate/inftrees.h`, `zlib_inflate/inffast.h`.
- Detected declarations: `function nofill`, `function __gunzip`, `function gunzip`, `function __decompress`.
- Atlas domain: Kernel Services / lib.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.