mirror of https://github.com/vitalif/e2fsprogs
libext2fs: fix ext2fs_get_memalign when posix_memalign() doesn't exist
Reported by: Gianluigi Tiesi <sherpya@netfarm.it> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>bitmap-optimize
parent
b75a4ce18c
commit
3a6db9bbc8
|
@ -26,6 +26,9 @@
|
||||||
#if HAVE_SYS_TYPES_H
|
#if HAVE_SYS_TYPES_H
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#endif
|
#endif
|
||||||
|
#if HAVE_MALLOC_H
|
||||||
|
#include <malloc.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "ext2_fs.h"
|
#include "ext2_fs.h"
|
||||||
#define INCLUDE_INLINE_FUNCS
|
#define INCLUDE_INLINE_FUNCS
|
||||||
|
@ -40,11 +43,12 @@ errcode_t ext2fs_get_memalign(unsigned long size,
|
||||||
unsigned long align, void *ptr)
|
unsigned long align, void *ptr)
|
||||||
{
|
{
|
||||||
errcode_t retval;
|
errcode_t retval;
|
||||||
|
void **p = ptr;
|
||||||
|
|
||||||
if (align == 0)
|
if (align == 0)
|
||||||
align = 8;
|
align = 8;
|
||||||
#ifdef HAVE_POSIX_MEMALIGN
|
#ifdef HAVE_POSIX_MEMALIGN
|
||||||
retval = posix_memalign((void **) ptr, align, size);
|
retval = posix_memalign(p, align, size);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
if (retval == ENOMEM)
|
if (retval == ENOMEM)
|
||||||
return EXT2_ET_NO_MEMORY;
|
return EXT2_ET_NO_MEMORY;
|
||||||
|
@ -52,8 +56,8 @@ errcode_t ext2fs_get_memalign(unsigned long size,
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#ifdef HAVE_MEMALIGN
|
#ifdef HAVE_MEMALIGN
|
||||||
*ptr = memalign(align, size);
|
*p = memalign(align, size);
|
||||||
if (*ptr == NULL) {
|
if (*p == NULL) {
|
||||||
if (errno)
|
if (errno)
|
||||||
return errno;
|
return errno;
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue