Re: Scope of snd_pcm_hw_params_alloca() ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At Fri, 14 Mar 2008 12:19:57 +0000,
Alan Horstmann wrote:
> 
> On Thursday 13 March 2008 16:44, you wrote:
> > At Thu, 13 Mar 2008 16:21:51 +0000,
> >
> > Alan Horstmann wrote:
> > > snd_pcm_hw_params_alloca() is part of the user API -right?  But
> > > accomplished as a #define in pcm.h.
> >
> > Because alloca can be used only with a macro due to its nature.
> >
> > > However if it is called inside a function, and the pointer stored for
> > > future use, after leaving the function the allocation seems to have gone,
> > > and attempting thereafter to use the pointer to access the hwparams space
> > > in another API function results in seg-fault.
> 
> So would it be better in this case to use the malloc /free functions if 
> possible?

No, it depends on your purpose.

The merit of alloca is that it's really a temporary variable that
requires no explicit destructor, and is faster and lighter than
malloc/free.  If you don't need to reuse it, you can safely use
alloca.  But if you need to reused the allocated record later, malloc
is the only choice.

>  Am I right that they are not provided in salsa, so alloca would be 
> necessary to use that lib?

Hm?  It's provided in SALSA, too.


Takashi
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux