diff options
Diffstat (limited to '')
-rw-r--r-- | cpukit/libcsupport/src/posix_memalign.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/cpukit/libcsupport/src/posix_memalign.c b/cpukit/libcsupport/src/posix_memalign.c index b2bef3e525..316ed7315c 100644 --- a/cpukit/libcsupport/src/posix_memalign.c +++ b/cpukit/libcsupport/src/posix_memalign.c @@ -24,18 +24,33 @@ #include <errno.h> int posix_memalign( - void **pointer, + void **memptr, size_t alignment, size_t size ) { - if (((alignment - 1) & alignment) != 0 || (alignment < sizeof(void *))) + RTEMS_OBFUSCATE_VARIABLE( memptr ); + + if ( memptr == NULL ) { + return EINVAL; + } + + *memptr = NULL; + + if ( alignment < sizeof( void * ) ) { return EINVAL; + } + + if ( ( ( alignment - 1 ) & alignment ) != 0 ) { + return EINVAL; + } + + *memptr = rtems_heap_allocate_aligned_with_boundary( size, alignment, 0 ); + + if ( *memptr == NULL ) { + return ENOMEM; + } - /* - * rtems_memalign does all of the error checking work EXCEPT - * for adding restrictionso on the alignment. - */ - return rtems_memalign( pointer, alignment, size ); + return 0; } #endif |