summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2016-07-15 09:23:33 +0900
committerTakashi Iwai <tiwai@suse.de>2016-07-15 08:16:36 +0200
commitfce5b6dcd1ad506768bd2d44890bb234d3ac0301 (patch)
treeb39d5cc35ad06475dd1da3e2caf740c8b967f3d3
parentb8e17cd852bd7fe071d0e29f0b1cdb9755731488 (diff)
downloadalsa-lib-fce5b6dcd1ad506768bd2d44890bb234d3ac0301.tar.gz
mixer: remove alloca() from simple_event_add()
Both of alloca() and automatic variables keep 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/mixer/simple_none.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/mixer/simple_none.c b/src/mixer/simple_none.c
index 9b0705cc..e129514c 100644
--- a/src/mixer/simple_none.c
+++ b/src/mixer/simple_none.c
@@ -1610,23 +1610,22 @@ static int simple_event_add(snd_mixer_class_t *class, snd_hctl_elem_t *helem)
if (snd_hctl_elem_get_interface(helem) != SND_CTL_ELEM_IFACE_MIXER)
return 0;
if (strcmp(name, "Capture Source") == 0) {
- snd_ctl_elem_info_t *info;
+ snd_ctl_elem_info_t info = {0};
unsigned int k, items;
int err;
- snd_ctl_elem_info_alloca(&info);
- err = snd_hctl_elem_info(helem, info);
+ err = snd_hctl_elem_info(helem, &info);
assert(err >= 0);
- if (snd_ctl_elem_info_get_type(info) !=
+ if (snd_ctl_elem_info_get_type(&info) !=
SND_CTL_ELEM_TYPE_ENUMERATED)
return 0;
- items = snd_ctl_elem_info_get_items(info);
+ items = snd_ctl_elem_info_get_items(&info);
for (k = 0; k < items; ++k) {
const char *n;
- snd_ctl_elem_info_set_item(info, k);
- err = snd_hctl_elem_info(helem, info);
+ snd_ctl_elem_info_set_item(&info, k);
+ err = snd_hctl_elem_info(helem, &info);
if (err < 0)
return err;
- n = snd_ctl_elem_info_get_item_name(info);
+ n = snd_ctl_elem_info_get_item_name(&info);
err = simple_add1(class, n, helem, CTL_CAPTURE_SOURCE,
k);
if (err < 0)