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 | ||||
| RROutputSetClones(RROutputPtr output, RROutputPtr * clones, int numClones) | ||||
| { | ||||
|     RROutputPtr *newClones; | ||||
|     int i; | ||||
| 
 | ||||
|     if (numClones == output->numClones) { | ||||
|  | @ -130,15 +129,16 @@ RROutputSetClones(RROutputPtr output, RROutputPtr * clones, int numClones) | |||
|         if (i == numClones) | ||||
|             return TRUE; | ||||
|     } | ||||
| 
 | ||||
|     RROutputPtr *newClones = NULL; | ||||
|     if (numClones) { | ||||
|         newClones = xallocarray(numClones, sizeof(RROutputPtr)); | ||||
|         if (!newClones) | ||||
|             return FALSE; | ||||
|         memcpy(newClones, clones, numClones * sizeof(RROutputPtr)); | ||||
|     } | ||||
|     else | ||||
|         newClones = NULL; | ||||
| 
 | ||||
|     free(output->clones); | ||||
|     memcpy(newClones, clones, numClones * sizeof(RROutputPtr)); | ||||
|     output->clones = newClones; | ||||
|     output->numClones = numClones; | ||||
|     RROutputChanged(output, TRUE); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue