| diff -ur a/malloc.c b/malloc.c |
| --- a/malloc.c 2007-05-14 10:26:14.000000000 -0700 |
| +++ b/malloc.c 2016-05-13 17:02:10.141760950 -0700 |
| @@ -81,6 +81,8 @@ |
| #include <signal.h> |
| #endif |
| |
| +#include <errno.h> |
| + |
| #define DMALLOC_DISABLE |
| |
| #include "dmalloc.h" |
| @@ -1209,6 +1211,30 @@ |
| 0 /* no xalloc messages */); |
| } |
| |
| +#undef posix_memalign |
| +int posix_memalign(DMALLOC_PNT *ppnt, DMALLOC_SIZE alignment, DMALLOC_SIZE size) |
| +{ |
| + int ret = 0;; |
| + DMALLOC_PNT pnt; |
| + |
| + if ((alignment & (alignment - 1)) != 0) { |
| + ret = -EINVAL; |
| + } |
| + |
| + if (ret >= 0) { |
| + pnt = memalign(alignment, size); |
| + if (pnt == NULL) { |
| + ret = -ENOMEM; |
| + } |
| + } |
| + |
| + if (ret >= 0) { |
| + *ppnt = pnt; |
| + } |
| + |
| + return ret; |
| +} |
| + |
| /* |
| * DMALLOC_PNT valloc |
| * |
| diff -ur a/malloc_funcs.h b/malloc_funcs.h |
| --- a/malloc_funcs.h 2007-05-14 10:26:14.000000000 -0700 |
| +++ b/malloc_funcs.h 2016-05-13 17:01:21.817144140 -0700 |
| @@ -129,6 +129,8 @@ |
| */ |
| extern |
| DMALLOC_PNT memalign(DMALLOC_SIZE alignment, DMALLOC_SIZE size); |
| +extern |
| +int posix_memalign(DMALLOC_PNT *ppnt, DMALLOC_SIZE alignment, DMALLOC_SIZE size); |
| |
| /* |
| * Allocate and return a SIZE block of bytes that has been aligned to |