From: Takashi Sakamoto Date: Thu, 14 Jul 2016 14:07:39 +0000 (+0900) Subject: pcm: remove alloca() from _snd_pcm_softvol_open() X-Git-Tag: v1.1.2~55 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=d745fcd5f7811d8e13d53dda73b74c4ce1e29b94;p=alsa-lib.git pcm: remove alloca() from _snd_pcm_softvol_open() 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 Signed-off-by: Takashi Iwai --- diff --git a/src/pcm/pcm_softvol.c b/src/pcm/pcm_softvol.c index e2345b35..61357785 100644 --- a/src/pcm/pcm_softvol.c +++ b/src/pcm/pcm_softvol.c @@ -995,7 +995,7 @@ int _snd_pcm_softvol_open(snd_pcm_t **pcmp, const char *name, snd_config_t *slave = NULL, *sconf; snd_config_t *control = NULL; snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN; - snd_ctl_elem_id_t *ctl_id; + snd_ctl_elem_id_t ctl_id = {0}; int resolution = PRESET_RESOLUTION; double min_dB = PRESET_MIN_DB; double max_dB = ZERO_DB; @@ -1074,7 +1074,6 @@ int _snd_pcm_softvol_open(snd_pcm_t **pcmp, const char *name, mode, conf); snd_config_delete(sconf); } else { - snd_ctl_elem_id_alloca(&ctl_id); err = snd_pcm_slave_conf(root, slave, &sconf, 1, SND_PCM_HW_PARAM_FORMAT, 0, &sformat); if (err < 0) @@ -1093,13 +1092,13 @@ int _snd_pcm_softvol_open(snd_pcm_t **pcmp, const char *name, snd_config_delete(sconf); if (err < 0) return err; - err = snd_pcm_parse_control_id(control, ctl_id, &card, + err = snd_pcm_parse_control_id(control, &ctl_id, &card, &cchannels, NULL); if (err < 0) { snd_pcm_close(spcm); return err; } - err = snd_pcm_softvol_open(pcmp, name, sformat, card, ctl_id, + err = snd_pcm_softvol_open(pcmp, name, sformat, card, &ctl_id, cchannels, min_dB, max_dB, resolution, spcm, 1); if (err < 0)