summaryrefslogtreecommitdiffstats
path: root/lib/decompress_unlz4.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2016-03-29 13:07:09 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2016-04-08 13:33:18 +0200
commit3bafe5eac5b48193607c4617f32d9e5e2075189f (patch)
treea9a524dae075f47b4b5b9ac8896fec4fe34410a1 /lib/decompress_unlz4.c
parent68bd0e50360fd97914e0716f4c9d81ceb980e3ba (diff)
downloadbarebox-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_unlz4.c')
-rw-r--r--lib/decompress_unlz4.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/decompress_unlz4.c b/lib/decompress_unlz4.c
index 0dfb08c7d7..46a010ad4c 100644
--- a/lib/decompress_unlz4.c
+++ b/lib/decompress_unlz4.c
@@ -15,6 +15,8 @@
#else
#include <linux/decompress/unlz4.h>
#include <malloc.h>
+#define MALLOC malloc
+#define FREE free
#endif
#include <linux/types.h>
#include <linux/lz4.h>
@@ -62,7 +64,7 @@ static inline int unlz4(u8 *input, int in_len,
error("NULL output pointer and no flush function provided");
goto exit_0;
} else {
- outp = malloc(uncomp_chunksize);
+ outp = MALLOC(uncomp_chunksize);
if (!outp) {
error("Could not allocate output buffer");
goto exit_0;
@@ -78,7 +80,7 @@ static inline int unlz4(u8 *input, int in_len,
error("NULL input pointer and missing fill function");
goto exit_1;
} else {
- inp = malloc(lz4_compressbound(uncomp_chunksize));
+ inp = MALLOC(lz4_compressbound(uncomp_chunksize));
if (!inp) {
error("Could not allocate input buffer");
goto exit_1;
@@ -171,10 +173,10 @@ static inline int unlz4(u8 *input, int in_len,
ret = 0;
exit_2:
if (!input)
- free(inp_start);
+ FREE(inp_start);
exit_1:
if (!output)
- free(outp);
+ FREE(outp);
exit_0:
return ret;
}