From 3a6db9bbc8a5aa85c200e66fc0563a1e87417efe Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 26 Mar 2012 15:37:28 -0700 Subject: [PATCH] libext2fs: fix ext2fs_get_memalign when posix_memalign() doesn't exist Reported by: Gianluigi Tiesi Signed-off-by: "Theodore Ts'o" --- lib/ext2fs/inline.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/ext2fs/inline.c b/lib/ext2fs/inline.c index d7869370..ad0c3683 100644 --- a/lib/ext2fs/inline.c +++ b/lib/ext2fs/inline.c @@ -26,6 +26,9 @@ #if HAVE_SYS_TYPES_H #include #endif +#if HAVE_MALLOC_H +#include +#endif #include "ext2_fs.h" #define INCLUDE_INLINE_FUNCS @@ -40,11 +43,12 @@ errcode_t ext2fs_get_memalign(unsigned long size, unsigned long align, void *ptr) { errcode_t retval; + void **p = ptr; if (align == 0) align = 8; #ifdef HAVE_POSIX_MEMALIGN - retval = posix_memalign((void **) ptr, align, size); + retval = posix_memalign(p, align, size); if (retval) { if (retval == ENOMEM) return EXT2_ET_NO_MEMORY; @@ -52,8 +56,8 @@ errcode_t ext2fs_get_memalign(unsigned long size, } #else #ifdef HAVE_MEMALIGN - *ptr = memalign(align, size); - if (*ptr == NULL) { + *p = memalign(align, size); + if (*p == NULL) { if (errno) return errno; else -- 2.11.0