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
acec1156b3
commit
b67dabef12
|
@ -251,7 +251,6 @@ RROutputDeleteUserMode(RROutputPtr output, RRModePtr mode)
|
|||
Bool
|
||||
RROutputSetCrtcs(RROutputPtr output, RRCrtcPtr * crtcs, int numCrtcs)
|
||||
{
|
||||
RRCrtcPtr *newCrtcs;
|
||||
int i;
|
||||
|
||||
if (numCrtcs == output->numCrtcs) {
|
||||
|
@ -261,15 +260,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