Date: Mon, 6 Jul 2009 20:26:08 +0200 From: Fabian Keil <freebsd-listen@fabiankeil.de> To: freebsd-hackers@freebsd.org Subject: Re: Zero-length allocation with posix_memalign() Message-ID: <20090706202608.45c98821@fabiankeil.de> In-Reply-To: <4A50E3F2.8080008@FreeBSD.org> References: <20090705182856.799b6b07@fabiankeil.de> <4A50E3F2.8080008@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --] Jason Evans <jasone@FreeBSD.org> wrote: > Fabian Keil wrote: > > Rémi Denis-Courmont, one of the vlc developers, pointed out > > that passing a zero size to posix_memalign() should actually > > work, though: > > > > | In principle, while useless, there is no reason why allocating an empty > > | picture should not be possible. posix_memalign() does support zero-length > > | allocation anyway: > > | http://www.opengroup.org/onlinepubs/9699919799/functions/posix_memalign.html > > | | If the size of the space requested is 0, the behavior is > > | | implementation-defined; the value returned in memptr shall be either a > > | | null pointer or a unique pointer. > > Standards: So many to choose from. This behavior for posix_memalign was > only defined as of the 2008 standard (see the Issue 7 notes for > posix_memalign): > > https://www.opengroup.org/austin/interps/uploads/40/14543/AI-152.txt > > Such requirements are unfortunate, because they induce a performance > penalty for every call, just so that programs can avoid proper handling > of edge cases in the rare situations for which such edge cases are a > real possibility. > > I will add the pessimization to posix_memalign once the 8.0 freeze is > over. It will be quite some time before this behavior becomes > ubiquitous, so in the meanwhile it's probably a good idea to modify vlc > to avoid such allocation requests. Great, thanks. I agree and will forward the vlc patch to the maintainer of the FreeBSD port if getting it committed upstream fails. Fabian [-- Attachment #2 --] -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.12 (FreeBSD) iEYEARECAAYFAkpSQcYACgkQBYqIVf93VJ15jACdFF1748pnTxPqe/Yxl2qW53lk Cm8AoLn6d1kM13FsdDw+UiR7FTmLqSiq =fEG8 -----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090706202608.45c98821>
