From 05dfffa98d4853216a7bf4a4303605d94d34af0f Mon Sep 17 00:00:00 2001 From: Phillip Lougher Date: Thu, 6 Aug 2009 15:09:31 -0700 Subject: [PATCH] --- yaml --- r: 156432 b: refs/heads/master c: b1af4315d823a2b6659c5b14bc17f7bc61878ef4 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/lib/decompress_bunzip2.c | 22 ++++++++++++++++------ trunk/lib/decompress_unlzma.c | 21 ++++++++++++++++----- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/[refs] b/[refs] index 4f37075c63b6..cb7bf487cf9b 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: daeb6b6fbe27049f465c48a7d0ee5555c3b84064 +refs/heads/master: b1af4315d823a2b6659c5b14bc17f7bc61878ef4 diff --git a/trunk/lib/decompress_bunzip2.c b/trunk/lib/decompress_bunzip2.c index 708e2a86d87b..d3dc9f2beb27 100644 --- a/trunk/lib/decompress_bunzip2.c +++ b/trunk/lib/decompress_bunzip2.c @@ -45,9 +45,11 @@ */ -#ifndef STATIC +#ifdef STATIC +#define PREBOOT +#else #include -#endif /* !STATIC */ +#endif /* STATIC */ #include #include @@ -681,9 +683,7 @@ STATIC int INIT bunzip2(unsigned char *buf, int len, set_error_fn(error_fn); if (flush) outbuf = malloc(BZIP2_IOBUF_SIZE); - else - len -= 4; /* Uncompressed size hack active in pre-boot - environment */ + if (!outbuf) { error("Could not allocate output bufer"); return -1; @@ -733,4 +733,14 @@ STATIC int INIT bunzip2(unsigned char *buf, int len, return i; } -#define decompress bunzip2 +#ifdef PREBOOT +STATIC int INIT decompress(unsigned char *buf, int len, + int(*fill)(void*, unsigned int), + int(*flush)(void*, unsigned int), + unsigned char *outbuf, + int *pos, + void(*error_fn)(char *x)) +{ + return bunzip2(buf, len - 4, fill, flush, outbuf, pos, error_fn); +} +#endif diff --git a/trunk/lib/decompress_unlzma.c b/trunk/lib/decompress_unlzma.c index 32123a1340e6..d3f9468e49dc 100644 --- a/trunk/lib/decompress_unlzma.c +++ b/trunk/lib/decompress_unlzma.c @@ -29,7 +29,9 @@ *Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef STATIC +#ifdef STATIC +#define PREBOOT +#else #include #endif /* STATIC */ @@ -543,9 +545,7 @@ STATIC inline int INIT unlzma(unsigned char *buf, int in_len, int ret = -1; set_error_fn(error_fn); - if (!flush) - in_len -= 4; /* Uncompressed size hack active in pre-boot - environment */ + if (buf) inbuf = buf; else @@ -645,4 +645,15 @@ STATIC inline int INIT unlzma(unsigned char *buf, int in_len, return ret; } -#define decompress unlzma +#ifdef PREBOOT +STATIC int INIT decompress(unsigned char *buf, int in_len, + int(*fill)(void*, unsigned int), + int(*flush)(void*, unsigned int), + unsigned char *output, + int *posp, + void(*error_fn)(char *x) + ) +{ + return unlzma(buf, in_len - 4, fill, flush, output, posp, error_fn); +} +#endif