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
|
Bool
|
||||||
RROutputSetCrtcs(RROutputPtr output, RRCrtcPtr * crtcs, int numCrtcs)
|
RROutputSetCrtcs(RROutputPtr output, RRCrtcPtr * crtcs, int numCrtcs)
|
||||||
{
|
{
|
||||||
RRCrtcPtr *newCrtcs;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (numCrtcs == output->numCrtcs) {
|
if (numCrtcs == output->numCrtcs) {
|
||||||
|
@ -261,15 +260,16 @@ RROutputSetCrtcs(RROutputPtr output, RRCrtcPtr * crtcs, int numCrtcs)
|
||||||
if (i == numCrtcs)
|
if (i == numCrtcs)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RRCrtcPtr *newCrtcs = NULL;
|
||||||
if (numCrtcs) {
|
if (numCrtcs) {
|
||||||
newCrtcs = xallocarray(numCrtcs, sizeof(RRCrtcPtr));
|
newCrtcs = xallocarray(numCrtcs, sizeof(RRCrtcPtr));
|
||||||
if (!newCrtcs)
|
if (!newCrtcs)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
memcpy(newCrtcs, crtcs, numCrtcs * sizeof(RRCrtcPtr));
|
||||||
}
|
}
|
||||||
else
|
|
||||||
newCrtcs = NULL;
|
|
||||||
free(output->crtcs);
|
free(output->crtcs);
|
||||||
memcpy(newCrtcs, crtcs, numCrtcs * sizeof(RRCrtcPtr));
|
|
||||||
output->crtcs = newCrtcs;
|
output->crtcs = newCrtcs;
|
||||||
output->numCrtcs = numCrtcs;
|
output->numCrtcs = numCrtcs;
|
||||||
RROutputChanged(output, TRUE);
|
RROutputChanged(output, TRUE);
|
||||||
|
|
Loading…
Reference in New Issue