randr: RROutputSetClones(): simplify buffer allocation / copying
Instead of relying on memcpy() coping with NULL buffer when size == 0, move the call to the branch where we actually have things to copy. This also silences yet another analyzer warning. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
		
							parent
							
								
									5b13d85464
								
							
						
					
					
						commit
						3279b81d7b
					
				|  | @ -120,7 +120,6 @@ RROutputCreate(ScreenPtr pScreen, | ||||||
| Bool | Bool | ||||||
| RROutputSetClones(RROutputPtr output, RROutputPtr * clones, int numClones) | RROutputSetClones(RROutputPtr output, RROutputPtr * clones, int numClones) | ||||||
| { | { | ||||||
|     RROutputPtr *newClones; |  | ||||||
|     int i; |     int i; | ||||||
| 
 | 
 | ||||||
|     if (numClones == output->numClones) { |     if (numClones == output->numClones) { | ||||||
|  | @ -130,15 +129,16 @@ RROutputSetClones(RROutputPtr output, RROutputPtr * clones, int numClones) | ||||||
|         if (i == numClones) |         if (i == numClones) | ||||||
|             return TRUE; |             return TRUE; | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     RROutputPtr *newClones = NULL; | ||||||
|     if (numClones) { |     if (numClones) { | ||||||
|         newClones = xallocarray(numClones, sizeof(RROutputPtr)); |         newClones = xallocarray(numClones, sizeof(RROutputPtr)); | ||||||
|         if (!newClones) |         if (!newClones) | ||||||
|             return FALSE; |             return FALSE; | ||||||
|  |         memcpy(newClones, clones, numClones * sizeof(RROutputPtr)); | ||||||
|     } |     } | ||||||
|     else | 
 | ||||||
|         newClones = NULL; |  | ||||||
|     free(output->clones); |     free(output->clones); | ||||||
|     memcpy(newClones, clones, numClones * sizeof(RROutputPtr)); |  | ||||||
|     output->clones = newClones; |     output->clones = newClones; | ||||||
|     output->numClones = numClones; |     output->numClones = numClones; | ||||||
|     RROutputChanged(output, TRUE); |     RROutputChanged(output, TRUE); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue