Mercurial > hg > dmlib
comparison tools/packed.c @ 2439:f81b42dd600d
Adjust few comments.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 25 Feb 2020 13:40:32 +0200 |
parents | 0b18f597351a |
children | 5b8cb850f5ab |
comparison
equal
deleted
inserted
replaced
2438:0b18f597351a | 2439:f81b42dd600d |
---|---|
347 | 347 |
348 // Read (and possibly compress) the data | 348 // Read (and possibly compress) the data |
349 if (compress) | 349 if (compress) |
350 { | 350 { |
351 int zret; | 351 int zret; |
352 | |
353 // Initialize compression streams | |
352 memset(&zstr, 0, sizeof(zstr)); | 354 memset(&zstr, 0, sizeof(zstr)); |
353 if (deflateInit(&zstr, level) != Z_OK) | 355 if (deflateInit(&zstr, level) != Z_OK) |
354 { | 356 { |
355 ret = DMERR_COMPRESSION; | 357 ret = DMERR_COMPRESSION; |
356 goto out; | 358 goto out; |
357 } | 359 } |
358 zinit = TRUE; | 360 zinit = TRUE; |
359 | 361 |
360 // Initialize compression streams | |
361 zret = Z_OK; | 362 zret = Z_OK; |
362 while (!feof(inFile) && zret == Z_OK) | 363 while (!feof(inFile) && zret == Z_OK) |
363 { | 364 { |
364 zstr.avail_in = fread(inBuffer, sizeof(Uint8), SET_TMPBUF_SIZE, inFile); | 365 zstr.avail_in = fread(inBuffer, sizeof(Uint8), SET_TMPBUF_SIZE, inFile); |
365 | 366 |
464 } | 465 } |
465 | 466 |
466 // Read and uncompress the data, if needed | 467 // Read and uncompress the data, if needed |
467 if (decompress || (entry->flags & DMF_COMPRESSED) == 0) | 468 if (decompress || (entry->flags & DMF_COMPRESSED) == 0) |
468 { | 469 { |
470 // Initialize compression streams | |
469 memset(&zstr, 0, sizeof(zstr)); | 471 memset(&zstr, 0, sizeof(zstr)); |
470 if (inflateInit(&zstr) != Z_OK) | 472 if (inflateInit(&zstr) != Z_OK) |
471 { | 473 { |
472 ret = DMERR_COMPRESSION; | 474 ret = DMERR_COMPRESSION; |
473 goto out; | 475 goto out; |
474 } | 476 } |
475 zinit = TRUE; | 477 zinit = TRUE; |
476 } | 478 } |
477 | 479 |
478 // Initialize compression streams | |
479 remaining = entry->length; | 480 remaining = entry->length; |
480 zret = Z_OK; | 481 zret = Z_OK; |
481 while (remaining > 0 && zret == Z_OK) | 482 while (remaining > 0 && zret == Z_OK) |
482 { | 483 { |
483 size_t needed = remaining > SET_TMPBUF_SIZE ? SET_TMPBUF_SIZE : remaining; | 484 size_t needed = remaining > SET_TMPBUF_SIZE ? SET_TMPBUF_SIZE : remaining; |