From: Theodore Ts'o Date: Mon, 26 Mar 2012 22:37:28 +0000 (-0700) Subject: libext2fs: fix ext2fs_get_memalign when posix_memalign() doesn't exist X-Git-Tag: v1.42.2~9 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=3a6db9bbc8a5aa85c200e66fc0563a1e87417efe;p=tools%2Fe2fsprogs.git libext2fs: fix ext2fs_get_memalign when posix_memalign() doesn't exist Reported by: Gianluigi Tiesi Signed-off-by: "Theodore Ts'o" --- diff --git a/lib/ext2fs/inline.c b/lib/ext2fs/inline.c index d786937..ad0c368 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