randr: RROutputSetCrtcs(): 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
							
								
									1e47daf592
								
							
						
					
					
						commit
						caed2ae6fc
					
				| 
						 | 
				
			
			@ -250,7 +250,6 @@ RROutputDeleteUserMode(RROutputPtr output, RRModePtr mode)
 | 
			
		|||
Bool
 | 
			
		||||
RROutputSetCrtcs(RROutputPtr output, RRCrtcPtr * crtcs, int numCrtcs)
 | 
			
		||||
{
 | 
			
		||||
    RRCrtcPtr *newCrtcs;
 | 
			
		||||
    int i;
 | 
			
		||||
 | 
			
		||||
    if (numCrtcs == output->numCrtcs) {
 | 
			
		||||
| 
						 | 
				
			
			@ -260,15 +259,16 @@ RROutputSetCrtcs(RROutputPtr output, RRCrtcPtr * crtcs, int numCrtcs)
 | 
			
		|||
        if (i == numCrtcs)
 | 
			
		||||
            return TRUE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    RRCrtcPtr *newCrtcs = NULL;
 | 
			
		||||
    if (numCrtcs) {
 | 
			
		||||
        newCrtcs = xallocarray(numCrtcs, sizeof(RRCrtcPtr));
 | 
			
		||||
        if (!newCrtcs)
 | 
			
		||||
            return FALSE;
 | 
			
		||||
        memcpy(newCrtcs, crtcs, numCrtcs * sizeof(RRCrtcPtr));
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
        newCrtcs = NULL;
 | 
			
		||||
 | 
			
		||||
    free(output->crtcs);
 | 
			
		||||
    memcpy(newCrtcs, crtcs, numCrtcs * sizeof(RRCrtcPtr));
 | 
			
		||||
    output->crtcs = newCrtcs;
 | 
			
		||||
    output->numCrtcs = numCrtcs;
 | 
			
		||||
    RROutputChanged(output, TRUE);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue