summaryrefslogtreecommitdiffstats
path: root/lib/decompress_unlzo.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_unlzo.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_unlzo.c')
-rw-r--r--lib/decompress_unlzo.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/decompress_unlzo.c b/lib/decompress_unlzo.c
index 10ad42ab14..ad7f977280 100644
--- a/lib/decompress_unlzo.c
+++ b/lib/decompress_unlzo.c
@@ -36,6 +36,8 @@
#include "lzo/lzo1x_decompress_safe.c"
#else
#include <malloc.h>
+#define MALLOC malloc
+#define FREE free
#endif
#include <lzo.h>
@@ -126,7 +128,7 @@ int decompress_unlzo(u8 *input, int in_len,
error("NULL output pointer and no flush function provided");
goto exit;
} else {
- out_buf = malloc(LZO_BLOCK_SIZE);
+ out_buf = MALLOC(LZO_BLOCK_SIZE);
if (!out_buf) {
error("Could not allocate output buffer");
goto exit;
@@ -142,7 +144,7 @@ int decompress_unlzo(u8 *input, int in_len,
error("NULL input pointer and missing fill function");
goto exit_1;
} else {
- in_buf = malloc(lzo1x_worst_compress(LZO_BLOCK_SIZE));
+ in_buf = MALLOC(lzo1x_worst_compress(LZO_BLOCK_SIZE));
if (!in_buf) {
error("Could not allocate input buffer");
goto exit_1;
@@ -278,10 +280,10 @@ int decompress_unlzo(u8 *input, int in_len,
ret = 0;
exit_2:
if (!input)
- free(in_buf_save);
+ FREE(in_buf_save);
exit_1:
if (!output)
- free(out_buf);
+ FREE(out_buf);
exit:
return ret;
}