mirror of
https://github.com/X11Libre/xserver.git
synced 2026-03-24 05:54:08 +00:00
randr: replace xallocarray() by calloc()
Only key difference that calloc(), in contrast to rellocarray(),
is zero-initializing. The overhead is hard to measure on today's
machines, and it's safer programming practise to always allocate
zero-initialized, so one can't forget to do it explicitly.
Cocci rule:
@@
expression COUNT;
expression LEN;
@@
- xallocarray(COUNT,LEN)
+ calloc(COUNT,LEN)
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
@@ -132,7 +132,7 @@ RROutputSetClones(RROutputPtr output, RROutputPtr * clones, int numClones)
|
||||
|
||||
RROutputPtr *newClones = NULL;
|
||||
if (numClones) {
|
||||
newClones = xallocarray(numClones, sizeof(RROutputPtr));
|
||||
newClones = calloc(numClones, sizeof(RROutputPtr));
|
||||
if (!newClones)
|
||||
return FALSE;
|
||||
memcpy(newClones, clones, numClones * sizeof(RROutputPtr));
|
||||
@@ -164,7 +164,7 @@ RROutputSetModes(RROutputPtr output,
|
||||
|
||||
RRModePtr *newModes = NULL;
|
||||
if (numModes) {
|
||||
newModes = xallocarray(numModes, sizeof(RRModePtr));
|
||||
newModes = calloc(numModes, sizeof(RRModePtr));
|
||||
if (!newModes)
|
||||
return FALSE;
|
||||
memcpy(newModes, modes, numModes * sizeof(RRModePtr));
|
||||
@@ -263,7 +263,7 @@ RROutputSetCrtcs(RROutputPtr output, RRCrtcPtr * crtcs, int numCrtcs)
|
||||
|
||||
RRCrtcPtr *newCrtcs = NULL;
|
||||
if (numCrtcs) {
|
||||
newCrtcs = xallocarray(numCrtcs, sizeof(RRCrtcPtr));
|
||||
newCrtcs = calloc(numCrtcs, sizeof(RRCrtcPtr));
|
||||
if (!newCrtcs)
|
||||
return FALSE;
|
||||
memcpy(newCrtcs, crtcs, numCrtcs * sizeof(RRCrtcPtr));
|
||||
|
||||
Reference in New Issue
Block a user