BCM WL 6.30.102.9 (r366174)
[tomato.git] / release / src-rt / linux / linux-2.6 / fs / squashfs / sqlzma.c
blobeec50623d428d3b4315dd5e42c6dda7066104443
1 #include <linux/init.h>
2 #include <linux/kernel.h>
3 #include <linux/vmalloc.h>
5 #include "LzmaDec.h"
6 #include "LzmaDec.c"
7 #include "sqlzma.h"
9 static void *SzAlloc(void *p, size_t size) { p = p; return vmalloc(size); }
10 static void SzFree(void *p, void *address) { p = p; vfree(address); }
11 static ISzAlloc g_Alloc = { SzAlloc, SzFree };
13 int LzmaUncompress(void *dst, int *dstlen, void *src, int srclen)
15 int res;
16 SizeT inSizePure;
17 ELzmaStatus status;
19 if (srclen < LZMA_PROPS_SIZE)
21 memcpy(dst, src, srclen);
22 return srclen;
24 inSizePure = srclen - LZMA_PROPS_SIZE;
25 res = LzmaDecode(dst, dstlen, src + LZMA_PROPS_SIZE, &inSizePure,
26 src, LZMA_PROPS_SIZE, LZMA_FINISH_ANY, &status, &g_Alloc);
27 srclen = inSizePure ;
29 if ((res == SZ_OK) ||
30 ((res == SZ_ERROR_INPUT_EOF) && (srclen == inSizePure)))
31 res = 0;
32 return res;