Re: posix_memalign(&ptr, 32, 0 fails)
Re: posix_memalign(&ptr, 32, 0 fails)
- Subject: Re: posix_memalign(&ptr, 32, 0 fails)
- From: Stan Sieler <email@hidden>
- Date: Wed, 27 Apr 2011 15:07:55 -0700
Re:
> http://www.kernel.org/doc/man-pages/online/pages/man3/posix_memalign.3.html
>
> "If size is 0, then posix_memalign() returns either NULL, or a unique pointer value that can later be successfully passed to free(3)."
>
> I'm not to keen on a function either returning NULL or something not NULL, but it would seem that when you align @ 32 here, you're getting a NULL return, hence the failure in FREE since nothing got malloc'ed in that case.
>
As it happens, the 32-byte & zero request *is* returning a non-NULL pointer ... it's just that the
"free" fails for some reason (perhaps incorrectly checking some internal housekeeping information).
(I added: printf (" ptr = %p\n", ptr); after each posix_memalign call.)
Just for testing clarity, I'd add "ptr = NULL;" after the two free() calls.
Speaking of keen, who decided a routine called posix_memalign would ***ALLOCATE*** data ... sheesh.
poxis_malloc_aligned would have been a much better name :)
(I'd have guessed from the name that it would take your pointer, and round it up (if needed) to
the next 32-byte boundary.)
Stan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden