MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / Decode

Function Decode

BaseTools/Source/C/LzmaCompress/LzmaCompress.c:174–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172}
173
174static SRes Decode(ISeqOutStream *outStream, ISeqInStream *inStream, UInt64 fileSize)
175{
176 SRes res;
177 size_t inSize = (size_t)fileSize;
178 Byte *inBuffer = 0;
179 Byte *outBuffer = 0;
180 size_t outSize = 0;
181 size_t inSizePure;
182 ELzmaStatus status;
183 UInt64 outSize64 = 0;
184
185 int i;
186
187 if (inSize < LZMA_HEADER_SIZE)
188 return SZ_ERROR_INPUT_EOF;
189
190 inBuffer = (Byte *)MyAlloc(inSize);
191 if (inBuffer == 0)
192 return SZ_ERROR_MEM;
193
194 if (SeqInStream_Read(inStream, inBuffer, inSize) != SZ_OK) {
195 res = SZ_ERROR_READ;
196 goto Done;
197 }
198
199 for (i = 0; i < 8; i++)
200 outSize64 += ((UInt64)inBuffer[LZMA_PROPS_SIZE + i]) << (i * 8);
201
202 outSize = (size_t)outSize64;
203 if (outSize != 0) {
204 outBuffer = (Byte *)MyAlloc(outSize);
205 if (outBuffer == 0) {
206 res = SZ_ERROR_MEM;
207 goto Done;
208 }
209 } else {
210 res = SZ_OK;
211 goto Done;
212 }
213
214 inSizePure = inSize - LZMA_HEADER_SIZE;
215 res = LzmaDecode(outBuffer, &outSize, inBuffer + LZMA_HEADER_SIZE, &inSizePure,
216 inBuffer, LZMA_PROPS_SIZE, LZMA_FINISH_END, &status, &g_Alloc);
217
218 if (res != SZ_OK)
219 goto Done;
220
221 if (mConType == X86Converter)
222 {
223 UInt32 x86State;
224 x86_Convert_Init(x86State);
225 x86_Convert(outBuffer, (SizeT) outSize, 0, &x86State, 0);
226 }
227
228 if (outStream->Write(outStream, outBuffer, outSize) != outSize)
229 res = SZ_ERROR_WRITE;
230
231Done:

Callers 1

main2Function · 0.70

Calls 7

SeqInStream_ReadFunction · 0.85
MyAllocFunction · 0.50
LzmaDecodeFunction · 0.50
x86_Convert_InitFunction · 0.50
x86_ConvertFunction · 0.50
MyFreeFunction · 0.50
WriteMethod · 0.45

Tested by

no test coverage detected