diff options
Diffstat (limited to 'src/gunzip.c')
-rw-r--r-- | src/gunzip.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/gunzip.c b/src/gunzip.c index 1d641ed..55c9e66 100644 --- a/src/gunzip.c +++ b/src/gunzip.c @@ -22,6 +22,7 @@ struct apk_gzip_istream { struct apk_bstream *bs; z_stream zs; int z_err; + int autoclose; }; static size_t gz_read(void *stream, void *ptr, size_t size) @@ -64,10 +65,12 @@ static void gz_close(void *stream) container_of(stream, struct apk_gzip_istream, is); inflateEnd(&gis->zs); + if (gis->autoclose) + gis->bs->close(gis->bs, NULL, NULL); free(gis); } -struct apk_istream *apk_bstream_gunzip(struct apk_bstream *bs) +struct apk_istream *apk_bstream_gunzip(struct apk_bstream *bs, int autoclose) { struct apk_gzip_istream *gis; @@ -83,6 +86,7 @@ struct apk_istream *apk_bstream_gunzip(struct apk_bstream *bs) .is.close = gz_close, .bs = bs, .z_err = 0, + .autoclose = autoclose, }; if (inflateInit2(&gis->zs, 15+32) != Z_OK) { |