summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2016-07-14 23:07:33 +0900
committerTakashi Iwai <tiwai@suse.de>2016-07-14 16:33:49 +0200
commit6a0c93a03dafaab66a6b2747d8b7142e69266027 (patch)
tree7b07a3fc75a677ddbd9a3251bc24b04777057290
parent34d2b6e96c0b90ef69a09ba51d9365b48b937feb (diff)
downloadalsa-lib-6a0c93a03dafaab66a6b2747d8b7142e69266027.tar.gz
pcm: remove alloca() from snd_pcm_hw_set_chmap()
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 <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--src/pcm/pcm_hw.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c
index 20c233b1..3a5634c1 100644
--- a/src/pcm/pcm_hw.c
+++ b/src/pcm/pcm_hw.c
@@ -1261,8 +1261,8 @@ static int snd_pcm_hw_set_chmap(snd_pcm_t *pcm, const snd_pcm_chmap_t *map)
{
snd_pcm_hw_t *hw = pcm->private_data;
snd_ctl_t *ctl;
- snd_ctl_elem_id_t *id;
- snd_ctl_elem_value_t *val;
+ snd_ctl_elem_id_t id = {0};
+ snd_ctl_elem_value_t val = {0};
unsigned int i;
int ret;
@@ -1287,13 +1287,12 @@ static int snd_pcm_hw_set_chmap(snd_pcm_t *pcm, const snd_pcm_chmap_t *map)
chmap_caps_set_error(hw, CHMAP_CTL_SET);
return ret;
}
- snd_ctl_elem_id_alloca(&id);
- snd_ctl_elem_value_alloca(&val);
- fill_chmap_ctl_id(pcm, id);
- snd_ctl_elem_value_set_id(val, id);
+
+ fill_chmap_ctl_id(pcm, &id);
+ snd_ctl_elem_value_set_id(&val, &id);
for (i = 0; i < map->channels; i++)
- snd_ctl_elem_value_set_integer(val, i, map->pos[i]);
- ret = snd_ctl_elem_write(ctl, val);
+ snd_ctl_elem_value_set_integer(&val, i, map->pos[i]);
+ ret = snd_ctl_elem_write(ctl, &val);
snd_ctl_close(ctl);
if (ret >= 0)
chmap_caps_set_ok(hw, CHMAP_CTL_SET);