Skip to content

Commit a9cc028

Browse files
committed
Simplify code
1 parent af9c37d commit a9cc028

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

Core/Libraries/Source/Compression/LZHCompress/NoxCompress.cpp

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -103,24 +103,19 @@ Bool DecompressFile (char *infile, char *outfile)
103103

104104
DEBUG_LOG(("Decompressed %s to %s, output size = %d", infile, outfile, rawSize));
105105

106+
Bool success = FALSE;
106107
LZHLDestroyDecompressor(decompress);
107108
outFilePtr = fopen(outfile, "wb");
108109
if (outFilePtr)
109110
{
110111
fwrite (outBlock, rawSize, 1, outFilePtr);
111112
fclose(outFilePtr);
112-
}
113-
else
114-
{
115-
if (inBlock) DbgFree(inBlock);
116-
if (outBlock) DbgFree(outBlock);
117-
return FALSE;
113+
success = TRUE;
118114
}
119115

120-
// Clean up this mess
121116
DbgFree(inBlock);
122117
DbgFree(outBlock);
123-
return TRUE;
118+
return success;
124119
} // End of if fileptr
125120

126121
return FALSE;
@@ -179,27 +174,21 @@ Bool CompressFile (char *infile, char *outfile)
179174
compressedSize += compressed;
180175
}
181176

177+
Bool success = FALSE;
182178
LZHLDestroyCompressor(compressor);
183-
184179
outFilePtr = fopen(outfile, "wb");
185180
if (outFilePtr)
186181
{
187182
// write out the uncompressed size first.
188183
fwrite(&rawSize, sizeof(UnsignedInt), 1, outFilePtr);
189184
fwrite(outBlock, compressedSize, 1, outFilePtr);
190185
fclose(outFilePtr);
191-
}
192-
else
193-
{
194-
DbgFree(inBlock);
195-
DbgFree(outBlock);
196-
return FALSE;
186+
success = TRUE;
197187
}
198188

199-
// Clean up
200189
DbgFree(inBlock);
201190
DbgFree(outBlock);
202-
return TRUE;
191+
return success;
203192
}
204193

205194
return FALSE;

0 commit comments

Comments
 (0)