diff options
Diffstat (limited to 'current/sources/android/support/src/posix_memalign.cpp')
-rw-r--r-- | current/sources/android/support/src/posix_memalign.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/current/sources/android/support/src/posix_memalign.cpp b/current/sources/android/support/src/posix_memalign.cpp new file mode 100644 index 000000000..cf7abbbf5 --- /dev/null +++ b/current/sources/android/support/src/posix_memalign.cpp @@ -0,0 +1,20 @@ +#include <errno.h> +#include <malloc.h> +#include <stdlib.h> + +int posix_memalign(void** memptr, size_t alignment, size_t size) { + if ((alignment & (alignment - 1)) != 0 || alignment == 0) { + return EINVAL; + } + + if (alignment % sizeof(void*) != 0) { + return EINVAL; + } + + *memptr = memalign(alignment, size); + if (*memptr == NULL) { + return errno; + } + + return 0; +} |