Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: third_party/lzma/v4_65/files/C/LzmaUtil/Lzma86Dec.c

Issue 624713003: Keep only base/extractor.[cc|h]. (Closed) Base URL: https://chromium.googlesource.com/external/omaha.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /* Lzma86Dec.c -- LZMA + x86 (BCJ) Filter Decoder
2 2008-04-07
3 Igor Pavlov
4 Public domain */
5
6 #include "Lzma86Dec.h"
7
8 #include "../Alloc.h"
9 #include "../Bra.h"
10 #include "../LzmaDec.h"
11
12 #define LZMA86_SIZE_OFFSET (1 + LZMA_PROPS_SIZE)
13 #define LZMA86_HEADER_SIZE (LZMA86_SIZE_OFFSET + 8)
14
15 static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); }
16 static void SzFree(void *p, void *address) { p = p; MyFree(address); }
17 static ISzAlloc g_Alloc = { SzAlloc, SzFree };
18
19 SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize)
20 {
21 unsigned i;
22 if (srcLen < LZMA86_HEADER_SIZE)
23 return SZ_ERROR_INPUT_EOF;
24 *unpackSize = 0;
25 for (i = 0; i < sizeof(UInt64); i++)
26 *unpackSize += ((UInt64)src[LZMA86_SIZE_OFFSET + i]) << (8 * i);
27 return SZ_OK;
28 }
29
30 SRes Lzma86_Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen)
31 {
32 SRes res;
33 int useFilter;
34 SizeT inSizePure;
35 ELzmaStatus status;
36
37 if (*srcLen < LZMA86_HEADER_SIZE)
38 return SZ_ERROR_INPUT_EOF;
39
40 useFilter = src[0];
41
42 if (useFilter > 1)
43 {
44 *destLen = 0;
45 return SZ_ERROR_UNSUPPORTED;
46 }
47
48 inSizePure = *srcLen - LZMA86_HEADER_SIZE;
49 res = LzmaDecode(dest, destLen, src + LZMA86_HEADER_SIZE, &inSizePure,
50 src + 1, LZMA_PROPS_SIZE, LZMA_FINISH_ANY, &status, &g_Alloc);
51 *srcLen = inSizePure + LZMA86_HEADER_SIZE;
52 if (res != SZ_OK)
53 return res;
54 if (useFilter == 1)
55 {
56 UInt32 x86State;
57 x86_Convert_Init(x86State);
58 x86_Convert(dest, *destLen, 0, &x86State, 0);
59 }
60 return SZ_OK;
61 }
OLDNEW
« no previous file with comments | « third_party/lzma/v4_65/files/C/LzmaUtil/Lzma86Dec.h ('k') | third_party/lzma/v4_65/files/C/LzmaUtil/Lzma86Enc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698