summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
Diffstat (limited to 'libc')
-rw-r--r--libc/stdlib/posix_memalign.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/libc/stdlib/posix_memalign.c b/libc/stdlib/posix_memalign.c
index 523bc2cbd..01831070f 100644
--- a/libc/stdlib/posix_memalign.c
+++ b/libc/stdlib/posix_memalign.c
@@ -34,8 +34,10 @@ int posix_memalign(void **memptr, size_t alignment, size_t size)
|| alignment == 0
*/
return EINVAL;
-
- *memptr = memalign(alignment, size);
-
- return (*memptr != NULL ? 0 : ENOMEM);
+ void *mem = memalign(alignment, size);
+ if (mem != NULL) {
+ *memptr = mem;
+ return 0;
+ } else
+ return ENOMEM;
}