[Mplayer-cvslog] CVS: main/libao2 ao_alsa.c,1.2,1.3

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Fri Jul 2 15:49:40 CEST 2004


Hi,

> -    if ((ret = snd_pcm_status_malloc(&status)) < 0)
> -    {
> -	mp_msg(MSGT_AO,MSGL_ERR,"alsa-space: memory allocation error: %s\n", snd_strerror(ret));
> -	return(0);
> -    }
> +    snd_pcm_status_alloca(&status);

Why do you use alloca? In man alloca:

        The inlined code often consists of  a  single  instruction
        adjusting  the stack pointer, and does not check for stack
        overflow.  Thus, there is no NULL error return.

        The alloca function is machine and compiler dependent.  On
        many  systems its implementation is buggy. Its use is dis­
        couraged.

In case don't know much about these things here's the short version:
e.g.
char *str=alloca(4000);

does the same as

char str[4000];

only that it sometimes is slower and doesn't work. At least that's how I 
see it.

Because of the (IMHO extremely stupid) way alsa does things it will be 
neccessary to use either the *_malloc or *_alloca functions, but I still 
think switching to alloca isn't a good idea...

Greetings,
Reimar Döffinger




More information about the MPlayer-cvslog mailing list