mirror of
				https://github.com/alsa-project/alsa-lib.git
				synced 2025-11-03 09:01:52 -05:00 
			
		
		
		
	minor malloc changes
replace malloc + memset with calloc since calloc may skip the memset if returned memory comes directly from sbrk() use malloc instead of malloc if first thing done with allocated memory is to flip all bits to 1. Signed-off-by: Olivier Langlois <olivier@trillion01.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
		
							parent
							
								
									49ad6699e6
								
							
						
					
					
						commit
						670e228c69
					
				
					 2 changed files with 2 additions and 3 deletions
				
			
		| 
						 | 
					@ -3202,12 +3202,11 @@ int alsa_lisp(struct alisp_cfg *cfg, struct alisp_instance **_instance)
 | 
				
			||||||
	struct alisp_object *p, *p1;
 | 
						struct alisp_object *p, *p1;
 | 
				
			||||||
	int i, j, retval = 0;
 | 
						int i, j, retval = 0;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	instance = (struct alisp_instance *)malloc(sizeof(struct alisp_instance));
 | 
						instance = (struct alisp_instance *)calloc(1, sizeof(struct alisp_instance));
 | 
				
			||||||
	if (instance == NULL) {
 | 
						if (instance == NULL) {
 | 
				
			||||||
		nomem();
 | 
							nomem();
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	memset(instance, 0, sizeof(struct alisp_instance));
 | 
					 | 
				
			||||||
	instance->verbose = cfg->verbose && cfg->vout;
 | 
						instance->verbose = cfg->verbose && cfg->vout;
 | 
				
			||||||
	instance->warning = cfg->warning && cfg->wout;
 | 
						instance->warning = cfg->warning && cfg->wout;
 | 
				
			||||||
	instance->debug = cfg->debug && cfg->dout;
 | 
						instance->debug = cfg->debug && cfg->dout;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1326,7 +1326,7 @@ static int snd_pcm_ladspa_parse_bindings(snd_pcm_ladspa_plugin_t *lplug,
 | 
				
			||||||
			count = (unsigned int)(channel + 1);
 | 
								count = (unsigned int)(channel + 1);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (count > 0) {
 | 
						if (count > 0) {
 | 
				
			||||||
		array = (unsigned int *)calloc(count, sizeof(unsigned int));
 | 
							array = (unsigned int *)malloc(count * sizeof(unsigned int));
 | 
				
			||||||
		if (! array)
 | 
							if (! array)
 | 
				
			||||||
			return -ENOMEM;
 | 
								return -ENOMEM;
 | 
				
			||||||
		memset(array, 0xff, count * sizeof(unsigned int));
 | 
							memset(array, 0xff, count * sizeof(unsigned int));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue