3333#define DbgFree free
3434#define DEBUG_LOG (x ) {}
3535
36- static Bool CleanFilesOnSuccess (char * in, char * out)
37- {
38- // `in` and `out` will always be non-NULL at this point
39- DbgFree (in);
40- DbgFree (out);
41- return TRUE ;
42- }
43-
44- static Bool CleanFilesOnError (char * in, char * out)
45- {
46- if (in) DbgFree (in);
47- if (out) DbgFree (out);
48- return FALSE ;
49- }
50-
5136Bool DecompressFile (char *infile, char *outfile)
5237{
5338 UnsignedInt rawSize = 0 , compressedSize = 0 ;
@@ -85,7 +70,9 @@ Bool DecompressFile (char *infile, char *outfile)
8570
8671 if (( inBlock == NULL ) || ( outBlock == NULL ))
8772 {
88- return CleanFilesOnError (inBlock, outBlock);
73+ if (inBlock) DbgFree (inBlock);
74+ if (outBlock) DbgFree (outBlock);
75+ return FALSE ;
8976 }
9077
9178 // Read in a big chunk o file
@@ -123,11 +110,15 @@ Bool DecompressFile (char *infile, char *outfile)
123110 }
124111 else
125112 {
126- return CleanFilesOnError (inBlock, outBlock);
113+ if (inBlock) DbgFree (inBlock);
114+ if (outBlock) DbgFree (outBlock);
115+ return FALSE ;
127116 }
128117
129118 // Clean up this mess
130- return CleanFilesOnSuccess (inBlock, outBlock);
119+ DbgFree (inBlock);
120+ DbgFree (outBlock);
121+ return TRUE ;
131122 } // End of if fileptr
132123
133124 return FALSE ;
@@ -149,6 +140,8 @@ Bool CompressFile (char *infile, char *outfile)
149140
150141 if (( infile == NULL ) || ( outfile == NULL ))
151142 {
143+ if (infile) DbgFree (infile);
144+ if (outfile) DbgFree (outfile);
152145 return FALSE ;
153146 }
154147
@@ -167,7 +160,9 @@ Bool CompressFile (char *infile, char *outfile)
167160
168161 if (( inBlock == NULL ) || ( outBlock == NULL ))
169162 {
170- return CleanFilesOnError (inBlock, outBlock);
163+ DbgFree (inBlock);
164+ DbgFree (outBlock);
165+ return FALSE ;
171166 }
172167
173168 // Read in a big chunk o file
@@ -196,11 +191,15 @@ Bool CompressFile (char *infile, char *outfile)
196191 }
197192 else
198193 {
199- return CleanFilesOnError (inBlock, outBlock);
194+ DbgFree (inBlock);
195+ DbgFree (outBlock);
196+ return FALSE ;
200197 }
201198
202199 // Clean up
203- return CleanFilesOnSuccess (inBlock, outBlock);
200+ DbgFree (inBlock);
201+ DbgFree (outBlock);
202+ return TRUE ;
204203 }
205204
206205 return FALSE ;
0 commit comments