diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2016-07-14 23:07:28 +0900 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2016-07-14 16:33:48 +0200 |
commit | 955d989e81b400fe985928e9dfdd8d9be785ab32 (patch) | |
tree | 9335761a409c7628009fbf3dd6d390e4939f8f05 | |
parent | f7c60897d9437c72682d448322711b661a86d2e0 (diff) | |
download | alsa-lib-955d989e81b400fe985928e9dfdd8d9be785ab32.tar.gz |
pcm: remove alloca() from _snd_pcm_hook_ctl_elems_install()
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_hooks.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/pcm/pcm_hooks.c b/src/pcm/pcm_hooks.c index ce1cf361..66e70513 100644 --- a/src/pcm/pcm_hooks.c +++ b/src/pcm/pcm_hooks.c @@ -667,7 +667,7 @@ int _snd_pcm_hook_ctl_elems_install(snd_pcm_t *pcm, snd_config_t *conf) { int err; int card; - snd_pcm_info_t *info; + snd_pcm_info_t info = {0}; char ctl_name[16]; snd_ctl_t *ctl; snd_sctl_t *sctl = NULL; @@ -675,11 +675,11 @@ int _snd_pcm_hook_ctl_elems_install(snd_pcm_t *pcm, snd_config_t *conf) snd_pcm_hook_t *h_hw_params = NULL, *h_hw_free = NULL, *h_close = NULL; assert(conf); assert(snd_config_get_type(conf) == SND_CONFIG_TYPE_COMPOUND); - snd_pcm_info_alloca(&info); - err = snd_pcm_info(pcm, info); + + err = snd_pcm_info(pcm, &info); if (err < 0) return err; - card = snd_pcm_info_get_card(info); + card = snd_pcm_info_get_card(&info); if (card < 0) { SNDERR("No card for this PCM"); return -EINVAL; |