File 0002-alsactl-move-alloca-out-of-loop.patch of Package alsa-utils

From ad47784b01b9dd532ba2c2249547ce55505bbf08 Mon Sep 17 00:00:00 2001
From: Clemens Ladisch <clemens@ladisch.de>
Date: Wed, 26 May 2010 10:18:43 +0200
Subject: [PATCH 02/13] alsactl: move alloca out of loop

Reserving new space from the stack in every loop iteration is not
necessary, so move the call to snd_ctl_elem_id_alloca outside where it
is executed only once.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
---
 alsactl/state.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/alsactl/state.c b/alsactl/state.c
index a9ffeea..86f7748 100644
--- a/alsactl/state.c
+++ b/alsactl/state.c
@@ -523,6 +523,7 @@ static int get_controls(int cardno, snd_config_t *top)
 	snd_ctl_card_info_t *info;
 	snd_config_t *state, *card, *control;
 	snd_ctl_elem_list_t *list;
+	snd_ctl_elem_id_t *elem_id;
 	unsigned int idx;
 	int err;
 	char name[32];
@@ -530,6 +531,7 @@ static int get_controls(int cardno, snd_config_t *top)
 	const char *id;
 	snd_ctl_card_info_alloca(&info);
 	snd_ctl_elem_list_alloca(&list);
+	snd_ctl_elem_id_alloca(&elem_id);
 
 	sprintf(name, "hw:%d", cardno);
 	err = snd_ctl_open(&handle, name, SND_CTL_READONLY);
@@ -604,10 +606,8 @@ static int get_controls(int cardno, snd_config_t *top)
 		goto _free;
 	}
 	for (idx = 0; idx < count; ++idx) {
-		snd_ctl_elem_id_t *id;
-		snd_ctl_elem_id_alloca(&id);
-		snd_ctl_elem_list_get_id(list, idx, id);
-		err = get_control(handle, id, control);
+		snd_ctl_elem_list_get_id(list, idx, elem_id);
+		err = get_control(handle, elem_id, control);
 		if (err < 0)
 			goto _free;
 	}		
-- 
1.7.2.1

openSUSE Build Service is sponsored by