]> git.alsa-project.org Git - alsa-lib.git/commitdiff
conf: remove alloca() from snd_func_private_pcm_subdevice()
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Thu, 14 Jul 2016 14:07:45 +0000 (23:07 +0900)
committerTakashi Iwai <tiwai@suse.de>
Thu, 14 Jul 2016 14:33:52 +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/confmisc.c

index 99be48b8b6b67db388df43150d928eec2082d26f..a985f1434dd9928164f6cb79f9ac3fb62f051580 100644 (file)
@@ -1162,7 +1162,7 @@ SND_DLSYM_BUILD_VERSION(snd_func_pcm_args_by_class, SND_CONFIG_DLSYM_VERSION_EVA
 int snd_func_private_pcm_subdevice(snd_config_t **dst, snd_config_t *root ATTRIBUTE_UNUSED,
                                   snd_config_t *src, snd_config_t *private_data)
 {
-       snd_pcm_info_t *info;
+       snd_pcm_info_t info = {0};
        const char *id;
        const void *data;
        snd_pcm_t *pcm;
@@ -1181,15 +1181,15 @@ int snd_func_private_pcm_subdevice(snd_config_t **dst, snd_config_t *root ATTRIB
                SNDERR("field pcm_handle is not a pointer");
                return err;
        }
-       snd_pcm_info_alloca(&info);
-       err = snd_pcm_info(pcm, info);
+       err = snd_pcm_info(pcm, &info);
        if (err < 0) {
                SNDERR("snd_ctl_pcm_info error: %s", snd_strerror(err));
                return err;
        }
        err = snd_config_get_id(src, &id);
        if (err >= 0)
-               err = snd_config_imake_integer(dst, id, snd_pcm_info_get_subdevice(info));
+               err = snd_config_imake_integer(dst, id,
+                                       snd_pcm_info_get_subdevice(&info));
        return err;
 }
 #ifndef DOC_HIDDEN