[Mplayer-cvslog] CVS: main spudec.c,1.30,1.31
pl
p_l at gmx.fr
Wed May 29 18:49:26 CEST 2002
On Wed, May 29, 2002 at 10:25:19AM +0200, Fredrik Kuivinen wrote:
> On Wed, May 29, 2002 at 02:33:06AM +0200, pl wrote:
> > + } else {
> > + // We'll get NULL if 0 byte is requested and it's not an error
> > + if (this->stride && this->height ) {
> > + fprintf(stderr,"Fatal: update_spu: malloc requested %d bytes\n", 2 * this->stride * this->height);
> > + }
>
> malloc will return a pointer != NULL if 0 bytes is requested (and the
> allocation did succeed). A simple test program shows this. The
> Linux manual page isn't very clear on the issue; the OpenBSD one
> describes it though
> (http://www.openbsd.org/cgi-bin/man.cgi?query=malloc&apropos=0&sektion=0&manpath=OpenBSD+Current&arch=i386&format=html).
I'd say the page is not even very clear... it's really misleading :)
Quoting malloc man page on nux:
"If size was equal to 0, either NULL or a pointer suitable to be passed
to free() is returned."
Thanks to these imprecisions I guess both flavors probablyexist with
different linux/malloc libs etc...
After rereading the code it should be ok (handled by the other 'if'
branch). Anyway I guess it would be better to avoid allocating 0 byte :)
--
Best regards,
pl
More information about the MPlayer-cvslog
mailing list