🎨 Simplify code
This commit is contained in:
parent
205642821f
commit
e6af0c35de
1 changed files with 13 additions and 14 deletions
|
@ -38,14 +38,14 @@ void inflateInit(uint8_t* comprBufferIn, uint8_t* uncomprBufferIn, unsigned long
|
||||||
|
|
||||||
struct InflateOutput inflateInflate(unsigned long numInputBytes, bool hasMoreBytes) {
|
struct InflateOutput inflateInflate(unsigned long numInputBytes, bool hasMoreBytes) {
|
||||||
if (numInputBytes == 0) {
|
if (numInputBytes == 0) {
|
||||||
//continue in input buffer where we were before
|
//Continue in input buffer where we were before
|
||||||
} else {
|
} else {
|
||||||
//go back to beginning of input buffer
|
//Go back to beginning of input buffer
|
||||||
comprBufferNext = comprBuffer;
|
comprBufferNext = comprBuffer;
|
||||||
remainingInput = numInputBytes;
|
remainingInput = numInputBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
//output buffer was previously fully filled and all output was processed. New uncompressed data can be written starting at offset 0
|
//Output buffer was previously fully filled and all output was processed. New uncompressed data can be written starting at offset 0
|
||||||
if (spaceInOutput == 0) {
|
if (spaceInOutput == 0) {
|
||||||
uncomprBufferNext = (mz_uint8 *)uncomprBuffer;
|
uncomprBufferNext = (mz_uint8 *)uncomprBuffer;
|
||||||
spaceInOutput = uncomprBufferSize;
|
spaceInOutput = uncomprBufferSize;
|
||||||
|
@ -77,17 +77,16 @@ struct InflateOutput inflateInflate(unsigned long numInputBytes, bool hasMoreByt
|
||||||
spaceInOutput -= out_bytes;
|
spaceInOutput -= out_bytes;
|
||||||
out.numBytesWrittenToOutput += out_bytes;
|
out.numBytesWrittenToOutput += out_bytes;
|
||||||
|
|
||||||
//Check for errors
|
//Check miniz output
|
||||||
if (status <= TINFL_STATUS_DONE) {
|
if (status == TINFL_STATUS_DONE) {
|
||||||
if (status == TINFL_STATUS_DONE) {
|
// Decompression completed successfully
|
||||||
// Decompression completed successfully.
|
out.hasReachedEnd = true;
|
||||||
out.hasReachedEnd = true;
|
break;
|
||||||
break;
|
}
|
||||||
} else {
|
if (status < TINFL_STATUS_DONE) {
|
||||||
// Decompression failed.
|
// Decompression failed
|
||||||
fprintf(stderr, "tinfl_decompress() failed with status %i!\n", status);
|
fprintf(stderr, "tinfl_decompress() failed with status %i!\n", status);
|
||||||
errorAndExit();
|
errorAndExit();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status == TINFL_STATUS_NEEDS_MORE_INPUT && remainingInput != 0) {
|
if (status == TINFL_STATUS_NEEDS_MORE_INPUT && remainingInput != 0) {
|
||||||
|
|
Loading…
Reference in a new issue