mirror of
				https://github.com/alsa-project/alsa-lib.git
				synced 2025-11-03 09:01:52 -05:00 
			
		
		
		
	mixer: remove alloca() from simple_add1()
Both of alloca() and automatic variables keep 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>
This commit is contained in:
		
							parent
							
								
									98194d5f98
								
							
						
					
					
						commit
						c2a59624f1
					
				
					 1 changed files with 9 additions and 10 deletions
				
			
		| 
						 | 
				
			
			@ -1419,18 +1419,17 @@ static int simple_add1(snd_mixer_class_t *class, const char *name,
 | 
			
		|||
	snd_mixer_selem_id_t *id;
 | 
			
		||||
	int new = 0;
 | 
			
		||||
	int err;
 | 
			
		||||
	snd_ctl_elem_info_t *info;
 | 
			
		||||
	snd_ctl_elem_info_t info = {0};
 | 
			
		||||
	selem_none_t *simple;
 | 
			
		||||
	const char *name1;
 | 
			
		||||
	snd_ctl_elem_type_t ctype;
 | 
			
		||||
	unsigned long values;
 | 
			
		||||
 | 
			
		||||
	snd_ctl_elem_info_alloca(&info);
 | 
			
		||||
	err = snd_hctl_elem_info(helem, info);
 | 
			
		||||
	err = snd_hctl_elem_info(helem, &info);
 | 
			
		||||
	if (err < 0)
 | 
			
		||||
		return err;
 | 
			
		||||
	ctype = snd_ctl_elem_info_get_type(info);
 | 
			
		||||
	values = snd_ctl_elem_info_get_count(info);
 | 
			
		||||
	ctype = snd_ctl_elem_info_get_type(&info);
 | 
			
		||||
	values = snd_ctl_elem_info_get_count(&info);
 | 
			
		||||
	switch (type) {
 | 
			
		||||
	case CTL_SINGLE:
 | 
			
		||||
		if (ctype == SND_CTL_ELEM_TYPE_ENUMERATED)
 | 
			
		||||
| 
						 | 
				
			
			@ -1553,20 +1552,20 @@ static int simple_add1(snd_mixer_class_t *class, const char *name,
 | 
			
		|||
		goto __error;
 | 
			
		||||
	}
 | 
			
		||||
	simple->ctls[type].elem = helem;
 | 
			
		||||
	simple->ctls[type].type = snd_ctl_elem_info_get_type(info);
 | 
			
		||||
	simple->ctls[type].inactive = snd_ctl_elem_info_is_inactive(info);
 | 
			
		||||
	simple->ctls[type].type = snd_ctl_elem_info_get_type(&info);
 | 
			
		||||
	simple->ctls[type].inactive = snd_ctl_elem_info_is_inactive(&info);
 | 
			
		||||
	simple->ctls[type].values = values;
 | 
			
		||||
	if ( (type == CTL_GLOBAL_ENUM) ||
 | 
			
		||||
	     (type == CTL_PLAYBACK_ENUM) ||
 | 
			
		||||
	     (type == CTL_CAPTURE_ENUM) ) {
 | 
			
		||||
		simple->ctls[type].min = 0;
 | 
			
		||||
		simple->ctls[type].max = snd_ctl_elem_info_get_items(info);
 | 
			
		||||
		simple->ctls[type].max = snd_ctl_elem_info_get_items(&info);
 | 
			
		||||
	} else {
 | 
			
		||||
		if (ctype == SND_CTL_ELEM_TYPE_INTEGER) {
 | 
			
		||||
			simple->ctls[type].min =
 | 
			
		||||
					snd_ctl_elem_info_get_min(info);
 | 
			
		||||
					snd_ctl_elem_info_get_min(&info);
 | 
			
		||||
			simple->ctls[type].max =
 | 
			
		||||
					snd_ctl_elem_info_get_max(info);
 | 
			
		||||
					snd_ctl_elem_info_get_max(&info);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	switch (type) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue