diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2016-03-29 13:07:09 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2016-04-08 13:33:18 +0200 |
commit | 3bafe5eac5b48193607c4617f32d9e5e2075189f (patch) | |
tree | a9a524dae075f47b4b5b9ac8896fec4fe34410a1 /lib/decompress_unxz.c | |
parent | 68bd0e50360fd97914e0716f4c9d81ceb980e3ba (diff) | |
download | barebox-3bafe5eac5b48193607c4617f32d9e5e2075189f.tar.gz barebox-3bafe5eac5b48193607c4617f32d9e5e2075189f.tar.xz |
decompressors: Use malloc/free wrappers
The decompressors are used both in a regular image and also for image
decompression. Both need different malloc implementations. Using
malloc/free directly in the decompressor code easily leads to include
file conflicts, so use MALLOC/FREE which can be defined correctly for
the two different usecases.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib/decompress_unxz.c')
-rw-r--r-- | lib/decompress_unxz.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/decompress_unxz.c b/lib/decompress_unxz.c index 1ddcee38ee..a7e2d331ab 100644 --- a/lib/decompress_unxz.c +++ b/lib/decompress_unxz.c @@ -109,6 +109,8 @@ #define XZ_EXTERN STATIC #ifndef XZ_PREBOOT +#define FREE free +#define MALLOC malloc # include <malloc.h> # include <linux/xz.h> #else @@ -258,14 +260,14 @@ STATIC int decompress_unxz(unsigned char *in, int in_size, b.out_size = (size_t)-1; } else { b.out_size = XZ_IOBUF_SIZE; - b.out = malloc(XZ_IOBUF_SIZE); + b.out = MALLOC(XZ_IOBUF_SIZE); if (b.out == NULL) goto error_alloc_out; } if (in == NULL) { must_free_in = true; - in = malloc(XZ_IOBUF_SIZE); + in = MALLOC(XZ_IOBUF_SIZE); if (in == NULL) goto error_alloc_in; } @@ -316,10 +318,10 @@ STATIC int decompress_unxz(unsigned char *in, int in_size, } while (ret == XZ_OK); if (must_free_in) - free(in); + FREE(in); if (flush != NULL) - free(b.out); + FREE(b.out); } if (in_used != NULL) @@ -359,7 +361,7 @@ STATIC int decompress_unxz(unsigned char *in, int in_size, error_alloc_in: if (flush != NULL) - free(b.out); + FREE(b.out); error_alloc_out: xz_dec_end(s); |