diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2010-05-26 10:18:43 +0200 |
---|---|---|
committer | Clemens Ladisch <clemens@ladisch.de> | 2010-05-26 10:18:43 +0200 |
commit | ad47784b01b9dd532ba2c2249547ce55505bbf08 (patch) | |
tree | b5b707ac44f511d23379eab8ced4048635e8fedf /alsactl | |
parent | e509df69a5100df28921980362488f6947df0aae (diff) |
alsactl: move alloca out of loop
Reserving new space from the stack in every loop iteration is not
necessary, so move the call to snd_ctl_elem_id_alloca outside where it
is executed only once.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Diffstat (limited to 'alsactl')
-rw-r--r-- | alsactl/state.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/alsactl/state.c b/alsactl/state.c index a9ffeea..86f7748 100644 --- a/alsactl/state.c +++ b/alsactl/state.c @@ -523,6 +523,7 @@ static int get_controls(int cardno, snd_config_t *top) snd_ctl_card_info_t *info; snd_config_t *state, *card, *control; snd_ctl_elem_list_t *list; + snd_ctl_elem_id_t *elem_id; unsigned int idx; int err; char name[32]; @@ -530,6 +531,7 @@ static int get_controls(int cardno, snd_config_t *top) const char *id; snd_ctl_card_info_alloca(&info); snd_ctl_elem_list_alloca(&list); + snd_ctl_elem_id_alloca(&elem_id); sprintf(name, "hw:%d", cardno); err = snd_ctl_open(&handle, name, SND_CTL_READONLY); @@ -604,10 +606,8 @@ static int get_controls(int cardno, snd_config_t *top) goto _free; } for (idx = 0; idx < count; ++idx) { - snd_ctl_elem_id_t *id; - snd_ctl_elem_id_alloca(&id); - snd_ctl_elem_list_get_id(list, idx, id); - err = get_control(handle, id, control); + snd_ctl_elem_list_get_id(list, idx, elem_id); + err = get_control(handle, elem_id, control); if (err < 0) goto _free; } |