summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2016-07-15 09:23:26 +0900
committerTakashi Iwai <tiwai@suse.de>2016-07-15 08:16:35 +0200
commit6ed747157395b83e4bf1a93088e73f06479beb5c (patch)
tree83378f99d4cb12161fa416c45d462d35edbdf896
parent1ad6d7b8523c0cf308503a8896258c1e47308e48 (diff)
downloadalsa-lib-6ed747157395b83e4bf1a93088e73f06479beb5c.tar.gz
mixer: remove alloca() from init_db_range()
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.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/mixer/simple_none.c b/src/mixer/simple_none.c
index 05dde413..0799ceb3 100644
--- a/src/mixer/simple_none.c
+++ b/src/mixer/simple_none.c
@@ -1098,7 +1098,7 @@ static int convert_to_dB(snd_hctl_elem_t *ctl, struct selem_str *rec,
*/
static int init_db_range(snd_hctl_elem_t *ctl, struct selem_str *rec)
{
- snd_ctl_elem_info_t *info;
+ snd_ctl_elem_info_t info = {0};
unsigned int *tlv = NULL;
const unsigned int tlv_size = 4096;
unsigned int *dbrec;
@@ -1109,10 +1109,9 @@ static int init_db_range(snd_hctl_elem_t *ctl, struct selem_str *rec)
if (rec->db_initialized)
return 0;
- snd_ctl_elem_info_alloca(&info);
- if (snd_hctl_elem_info(ctl, info) < 0)
+ if (snd_hctl_elem_info(ctl, &info) < 0)
goto error;
- if (!snd_ctl_elem_info_is_tlv_readable(info))
+ if (!snd_ctl_elem_info_is_tlv_readable(&info))
goto error;
tlv = malloc(tlv_size);
if (!tlv)