From ab74f60d3b8631633ff4164c57fbfb282a1aa7f3 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Mon, 08 May 2023 20:55:08 -0400 Subject: gzip: Separate last compression from freeing --- (limited to 'src/gzip.c') diff --git a/src/gzip.c b/src/gzip.c index ef4d4aa..0b5d7cf 100644 --- a/src/gzip.c +++ b/src/gzip.c @@ -229,6 +229,21 @@ opkg_opk_gzip_written(struct opkg_opk_gzip *gzip) } int +opkg_opk_gzip_finish_write(struct opkg_opk_gzip *gzip) +{ + /* Sanity check */ + if (gzip->dir != _OPKG_OPK_GZIP_DIR_WRITE) { + return OPKG_OPK_ERROR; + } + + if (gzip->written > 0 && _opkg_opk_gzip_write(gzip, NULL, 0, 1) != + OPKG_OPK_END) { + return OPKG_OPK_ERROR; + } + return OPKG_OPK_OK; +} + +int opkg_opk_gzip_free(struct opkg_opk_gzip *gzip) { int ret; @@ -239,9 +254,6 @@ opkg_opk_gzip_free(struct opkg_opk_gzip *gzip) ret = OPKG_OPK_ERROR; } } else { - if (_opkg_opk_gzip_write(gzip, NULL, 0, 1) != OPKG_OPK_END) { - ret = OPKG_OPK_ERROR; - } if (deflateEnd(&gzip->stream) != Z_OK) { ret = OPKG_OPK_ERROR; } -- cgit v0.9.1