]> git.alsa-project.org Git - alsa-lib.git/commitdiff
pcm: remove alloca() from _snd_pcm_softvol_open()
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Thu, 14 Jul 2016 14:07:39 +0000 (23:07 +0900)
committerTakashi Iwai <tiwai@suse.de>
Thu, 14 Jul 2016 14:33:51 +0000 (16:33 +0200)
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>
src/pcm/pcm_softvol.c

index e2345b3548cebd0a461f2bdbac3cb2c9dd64d034..61357785c97cd6b194a16858a3f37bf662078d88 100644 (file)
@@ -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)