Message ID | CA+yXCZDHCSvf+WxW+zOhwDkUm5Z_gQx6S9sqimwOVpT5OyCxEA@mail.gmail.com |
---|---|
State | Superseded |
Headers | show |
Hi Kito, Kito Cheng wrote, > Hi all: > > uclibc seem will set argument *memptr to NULL when posix_memalign[1] > fail, I know it's not specify in most document[1-3], > but other libc (newlib, glibc, musl) implementations are not set it to > NULL if fail and gcc testsuite have 1 test case for that[7], so how > about make uclib consistent to other libc? Thanks for the patch, I thought Ihad replied to this. I pushed the change, thanks Waldemar
From a7e46cb115fae7d4de1cedddb0cbf2932b9ddf39 Mon Sep 17 00:00:00 2001 From: Kito Cheng <kito.cheng@gmail.com> Date: Thu, 23 Feb 2017 17:16:28 +0800 Subject: [PATCH] Only set *memptr when success for posix_memalign --- libc/stdlib/posix_memalign.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libc/stdlib/posix_memalign.c b/libc/stdlib/posix_memalign.c index 523bc2c..0183107 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; } -- 2.8.2