star-hitran

Load line-by-line data from the HITRAN database
git clone git://git.meso-star.fr/star-hitran.git
Log | Files | Refs | README | LICENSE

commit 372d23022f0eb854716e8abf9aaa182ab5ecf9e6
parent 76ad8a9dd032763b70c2756f04097c2cbf17eb5f
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Mon, 12 Jan 2026 16:47:41 +0100

Compression/decompression fix

The inflate procedure failed when there were multiple compressed chunks.
Now, each chunk is treated as a separate stream, compressed/decompressed
independently of the others.

Diffstat:
Msrc/shtr_line_list.c | 11++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/shtr_line_list.c b/src/shtr_line_list.c @@ -79,7 +79,6 @@ zctx_init(struct zctx* zctx, struct shtr* shtr, const int level) res_T res = RES_OK; ASSERT(zctx && shtr); - *zctx = ZCTX_NULL; SHTR(ref_get(shtr)); @@ -139,8 +138,10 @@ zctx_deflate(struct zctx* zctx, struct shtr_line_list* list) zctx->stream.avail_out = ZCHUNK_MAX_SIZE; /* Compress */ - ret = deflate(&zctx->stream, Z_FULL_FLUSH); - if(ret != Z_OK) { res = RES_UNKNOWN_ERR; goto error; } + ret = deflate(&zctx->stream, Z_FINISH); + if(ret != Z_STREAM_END) { res = RES_UNKNOWN_ERR; goto error; } + + CHK(deflateReset(&zctx->stream) == Z_OK); /* Calculate the size after compression */ zchunk.size = ZCHUNK_MAX_SIZE - zctx->stream.avail_out; @@ -591,8 +592,8 @@ decompress_zchunk list->z_stream.avail_in = (uInt)zchunk->size; list->z_stream.next_out = (unsigned char*)lines; list->z_stream.avail_out = (uInt)(sizeof(struct line)*NLINES_PER_CHUNK); - ret = inflate(&list->z_stream, Z_SYNC_FLUSH); - if(ret != Z_OK) { + ret = inflate(&list->z_stream, Z_FINISH); + if(ret != Z_STREAM_END) { ASSERT(list->z_stream.msg); ERROR(list->shtr, "Error decompressing the chunk of lines -- %s\n", list->z_stream.msg);