From: Takashi Iwai Subject: Re: Scope of snd_pcm_hw_params_alloca() ? Date: Thu, 13 Mar 2008 17:44:27 +0100 Message-ID: References: <200803131621.51271.gineera@aspect135.co.uk> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx1.suse.de (ns.suse.de [195.135.220.2]) by alsa0.perex.cz (Postfix) with ESMTP id 67A21243F3 for ; Thu, 13 Mar 2008 17:44:31 +0100 (CET) In-Reply-To: <200803131621.51271.gineera@aspect135.co.uk> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Alan Horstmann Cc: ALSA devel List-Id: alsa-devel@alsa-project.org At Thu, 13 Mar 2008 16:21:51 +0000, Alan Horstmann wrote: > > I've spent a couple of days pining this down. > > 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. > > This seems rather counter-intuitive (ie unexpected) to someone who has no > knowledge of the inner workings, but simply uses the API; the allocation > disappears without having been specifically free'd or released in any way. I > know that calling it globally gets round the problem, but certainly I could > do without all the debug needed to discover that. Well, alloca() is an (almost) standard stuff. You had a good lecture for a bit more deep studying C :) Takashi