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/xz | |
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/xz')
-rw-r--r-- | lib/xz/xz_dec_bcj.c | 2 | ||||
-rw-r--r-- | lib/xz/xz_dec_lzma2.c | 14 | ||||
-rw-r--r-- | lib/xz/xz_dec_stream.c | 6 | ||||
-rw-r--r-- | lib/xz/xz_private.h | 4 |
4 files changed, 14 insertions, 12 deletions
diff --git a/lib/xz/xz_dec_bcj.c b/lib/xz/xz_dec_bcj.c index a768e6d28b..d268adbc65 100644 --- a/lib/xz/xz_dec_bcj.c +++ b/lib/xz/xz_dec_bcj.c @@ -526,7 +526,7 @@ XZ_EXTERN enum xz_ret xz_dec_bcj_run(struct xz_dec_bcj *s, XZ_EXTERN struct xz_dec_bcj *xz_dec_bcj_create(bool single_call) { - struct xz_dec_bcj *s = kmalloc(sizeof(*s), GFP_KERNEL); + struct xz_dec_bcj *s = MALLOC(sizeof(*s)); if (s != NULL) s->single_call = single_call; diff --git a/lib/xz/xz_dec_lzma2.c b/lib/xz/xz_dec_lzma2.c index 08c3c80499..87ffd95f2e 100644 --- a/lib/xz/xz_dec_lzma2.c +++ b/lib/xz/xz_dec_lzma2.c @@ -1108,7 +1108,7 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s, XZ_EXTERN struct xz_dec_lzma2 *xz_dec_lzma2_create(enum xz_mode mode, uint32_t dict_max) { - struct xz_dec_lzma2 *s = kmalloc(sizeof(*s), GFP_KERNEL); + struct xz_dec_lzma2 *s = MALLOC(sizeof(*s)); if (s == NULL) return NULL; @@ -1116,9 +1116,9 @@ XZ_EXTERN struct xz_dec_lzma2 *xz_dec_lzma2_create(enum xz_mode mode, s->dict.size_max = dict_max; if (DEC_IS_PREALLOC(mode)) { - s->dict.buf = vmalloc(dict_max); + s->dict.buf = MALLOC(dict_max); if (s->dict.buf == NULL) { - kfree(s); + FREE(s); return NULL; } } else if (DEC_IS_DYNALLOC(mode)) { @@ -1146,8 +1146,8 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_reset(struct xz_dec_lzma2 *s, uint8_t props) if (DEC_IS_DYNALLOC(s->dict.mode)) { if (s->dict.allocated < s->dict.size) { - vfree(s->dict.buf); - s->dict.buf = vmalloc(s->dict.size); + FREE(s->dict.buf); + s->dict.buf = MALLOC(s->dict.size); if (s->dict.buf == NULL) { s->dict.allocated = 0; return XZ_MEM_ERROR; @@ -1169,7 +1169,7 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_reset(struct xz_dec_lzma2 *s, uint8_t props) XZ_EXTERN void xz_dec_lzma2_end(struct xz_dec_lzma2 *s) { if (DEC_IS_MULTI(s->dict.mode)) - vfree(s->dict.buf); + FREE(s->dict.buf); - kfree(s); + FREE(s); } diff --git a/lib/xz/xz_dec_stream.c b/lib/xz/xz_dec_stream.c index ac809b1e64..fa1751dfca 100644 --- a/lib/xz/xz_dec_stream.c +++ b/lib/xz/xz_dec_stream.c @@ -769,7 +769,7 @@ XZ_EXTERN enum xz_ret xz_dec_run(struct xz_dec *s, struct xz_buf *b) XZ_EXTERN struct xz_dec *xz_dec_init(enum xz_mode mode, uint32_t dict_max) { - struct xz_dec *s = kmalloc(sizeof(*s), GFP_KERNEL); + struct xz_dec *s = MALLOC(sizeof(*s)); if (s == NULL) return NULL; @@ -793,7 +793,7 @@ error_lzma2: xz_dec_bcj_end(s->bcj); error_bcj: #endif - kfree(s); + FREE(s); return NULL; } @@ -816,6 +816,6 @@ XZ_EXTERN void xz_dec_end(struct xz_dec *s) #ifdef XZ_DEC_BCJ xz_dec_bcj_end(s->bcj); #endif - kfree(s); + FREE(s); } } diff --git a/lib/xz/xz_private.h b/lib/xz/xz_private.h index 99b8ade6cf..85f79635f0 100644 --- a/lib/xz/xz_private.h +++ b/lib/xz/xz_private.h @@ -39,6 +39,8 @@ # endif # define memeq(a, b, size) (memcmp(a, b, size) == 0) # define memzero(buf, size) memset(buf, 0, size) +# define FREE free +# define MALLOC malloc # endif # define get_le32(p) le32_to_cpup((const uint32_t *)(p)) #else @@ -150,7 +152,7 @@ XZ_EXTERN enum xz_ret xz_dec_bcj_run(struct xz_dec_bcj *s, struct xz_buf *b); /* Free the memory allocated for the BCJ filters. */ -#define xz_dec_bcj_end(s) kfree(s) +#define xz_dec_bcj_end(s) FREE(s) #endif #endif |