From 757c45b2ae3dddc23566f2dc511bf606607da000 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Thu, 14 Jul 2016 23:07:30 +0900 Subject: [PATCH] pcm: remove alloca() from snd_pcm_hw_change_timer() Both of alloca() and automatic variables keeps storages on stack, while the former generates more instructions than the latter. It's better to use the latter if the size of storage is computable at pre-compile or compile time; i.e. just for structures. This commit obsolete usages of alloca() with automatic variables. Signed-off-by: Takashi Sakamoto Signed-off-by: Takashi Iwai --- src/pcm/pcm_hw.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c index 0daaccc4..864d5fa2 100644 --- a/src/pcm/pcm_hw.c +++ b/src/pcm/pcm_hw.c @@ -351,12 +351,11 @@ static void snd_pcm_hw_close_timer(snd_pcm_hw_t *hw) static int snd_pcm_hw_change_timer(snd_pcm_t *pcm, int enable) { snd_pcm_hw_t *hw = pcm->private_data; - snd_timer_params_t *params; + snd_timer_params_t params = {0}; unsigned int suspend, resume; int err; if (enable) { - snd_timer_params_alloca(¶ms); err = snd_timer_hw_open(&hw->period_timer, "hw-pcm-period-event", SND_TIMER_CLASS_PCM, SND_TIMER_SCLASS_NONE, @@ -406,11 +405,11 @@ static int snd_pcm_hw_change_timer(snd_pcm_t *pcm, int enable) resume = 1<period_timer, params); + err = snd_timer_params(hw->period_timer, ¶ms); if (err < 0) { snd_pcm_hw_close_timer(hw); return err; -- 2.47.1