summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2016-07-14 23:07:32 +0900
committerTakashi Iwai <tiwai@suse.de>2016-07-14 16:33:49 +0200
commit34d2b6e96c0b90ef69a09ba51d9365b48b937feb (patch)
tree7d6c8fe03dfb8c8ccbe749a65fac4805a3c59cec /src
parent6fdaad70afb6c04a03ba48c111304467daa330b1 (diff)
downloadalsa-lib-34d2b6e96c0b90ef69a09ba51d9365b48b937feb.tar.gz
pcm: remove alloca() from snd_pcm_hw_get_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>
Diffstat (limited to 'src')
-rw-r--r--src/pcm/pcm_hw.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c
index e7a23939..20c233b1 100644
--- a/src/pcm/pcm_hw.c
+++ b/src/pcm/pcm_hw.c
@@ -1206,8 +1206,8 @@ static snd_pcm_chmap_t *snd_pcm_hw_get_chmap(snd_pcm_t *pcm)
snd_pcm_hw_t *hw = pcm->private_data;
snd_pcm_chmap_t *map;
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;
@@ -1241,11 +1241,9 @@ static snd_pcm_chmap_t *snd_pcm_hw_get_chmap(snd_pcm_t *pcm)
chmap_caps_set_error(hw, CHMAP_CTL_GET);
return NULL;
}
- snd_ctl_elem_value_alloca(&val);
- snd_ctl_elem_id_alloca(&id);
- fill_chmap_ctl_id(pcm, id);
- snd_ctl_elem_value_set_id(val, id);
- ret = snd_ctl_elem_read(ctl, val);
+ fill_chmap_ctl_id(pcm, &id);
+ snd_ctl_elem_value_set_id(&val, &id);
+ ret = snd_ctl_elem_read(ctl, &val);
snd_ctl_close(ctl);
if (ret < 0) {
free(map);
@@ -1254,7 +1252,7 @@ static snd_pcm_chmap_t *snd_pcm_hw_get_chmap(snd_pcm_t *pcm)
return NULL;
}
for (i = 0; i < pcm->channels; i++)
- map->pos[i] = snd_ctl_elem_value_get_integer(val, i);
+ map->pos[i] = snd_ctl_elem_value_get_integer(&val, i);
chmap_caps_set_ok(hw, CHMAP_CTL_GET);
return map;
}