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

Zsolt Barat joy at streamminister.de
Sat Jul 3 03:19:53 CEST 2004


Reimar Döffinger wrote:

> 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...

i dont't want to fight one of the malloc vers. alloca flamewars again 
which is fighted a million times before us. the man page you mentioning 
is from the sixties. alloca is much improved since then. since alsa is 
running mostly on linux (advanced linux sound architecture) we have no 
portability issues here.
so for short: i want to use the alloca functions in the alsa api cause:
1. the malloc functions are depreciated
2. it's cooler....

greetz joy




More information about the MPlayer-cvslog mailing list