diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2015-03-21 13:42:12 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2015-04-21 16:57:08 -0700 |
commit | 1c56ac63c040280498c4a9d67b48c35b60070821 (patch) | |
tree | ab1073d348cb1acf0523ede3e1f2fa73f3b5fdb6 /randr | |
parent | b9e665c8b2f048feb3064ce412e0b3e9eb6797b0 (diff) |
Convert top level extensions to new *allocarray functions
v2: remove now useless parentheses
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Diffstat (limited to 'randr')
-rw-r--r-- | randr/rrcrtc.c | 14 | ||||
-rw-r--r-- | randr/rrinfo.c | 10 | ||||
-rw-r--r-- | randr/rrmode.c | 4 | ||||
-rw-r--r-- | randr/rrmonitor.c | 5 | ||||
-rw-r--r-- | randr/rroutput.c | 14 | ||||
-rw-r--r-- | randr/rrproperty.c | 12 | ||||
-rw-r--r-- | randr/rrproviderproperty.c | 6 | ||||
-rw-r--r-- | randr/rrtransform.c | 2 |
8 files changed, 33 insertions, 34 deletions
diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index 69b3ecf0f..63d94e26a 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -65,8 +65,8 @@ RRCrtcCreate(ScreenPtr pScreen, void *devPrivate) /* make space for the crtc pointer */ if (pScrPriv->numCrtcs) - crtcs = realloc(pScrPriv->crtcs, - (pScrPriv->numCrtcs + 1) * sizeof(RRCrtcPtr)); + crtcs = reallocarray(pScrPriv->crtcs, + pScrPriv->numCrtcs + 1, sizeof(RRCrtcPtr)); else crtcs = malloc(sizeof(RRCrtcPtr)); if (!crtcs) @@ -176,10 +176,10 @@ RRCrtcNotify(RRCrtcPtr crtc, if (numOutputs) { if (crtc->numOutputs) - newoutputs = realloc(crtc->outputs, - numOutputs * sizeof(RROutputPtr)); + newoutputs = reallocarray(crtc->outputs, + numOutputs, sizeof(RROutputPtr)); else - newoutputs = malloc(numOutputs * sizeof(RROutputPtr)); + newoutputs = xallocarray(numOutputs, sizeof(RROutputPtr)); if (!newoutputs) return FALSE; } @@ -798,7 +798,7 @@ RRCrtcGammaSetSize(RRCrtcPtr crtc, int size) if (size == crtc->gammaSize) return TRUE; if (size) { - gamma = malloc(size * 3 * sizeof(CARD16)); + gamma = xallocarray(size, 3 * sizeof(CARD16)); if (!gamma) return FALSE; } @@ -1027,7 +1027,7 @@ ProcRRSetCrtcConfig(ClientPtr client) return BadMatch; } if (numOutputs) { - outputs = malloc(numOutputs * sizeof(RROutputPtr)); + outputs = xallocarray(numOutputs, sizeof(RROutputPtr)); if (!outputs) return BadAlloc; } diff --git a/randr/rrinfo.c b/randr/rrinfo.c index fc57bd408..24245b7b6 100644 --- a/randr/rrinfo.c +++ b/randr/rrinfo.c @@ -55,8 +55,8 @@ RROldModeAdd(RROutputPtr output, RRScreenSizePtr size, int refresh) } if (output->numModes) - modes = realloc(output->modes, - (output->numModes + 1) * sizeof(RRModePtr)); + modes = reallocarray(output->modes, + output->numModes + 1, sizeof(RRModePtr)); else modes = malloc(sizeof(RRModePtr)); if (!modes) { @@ -266,8 +266,8 @@ RRRegisterSize(ScreenPtr pScreen, for (i = 0; i < pScrPriv->nSizes; i++) if (RRScreenSizeMatches(&tmp, &pScrPriv->pSizes[i])) return &pScrPriv->pSizes[i]; - pNew = realloc(pScrPriv->pSizes, - (pScrPriv->nSizes + 1) * sizeof(RRScreenSize)); + pNew = reallocarray(pScrPriv->pSizes, + pScrPriv->nSizes + 1, sizeof(RRScreenSize)); if (!pNew) return 0; pNew[pScrPriv->nSizes++] = tmp; @@ -289,7 +289,7 @@ RRRegisterRate(ScreenPtr pScreen, RRScreenSizePtr pSize, int rate) if (pSize->pRates[i].rate == rate) return TRUE; - pNew = realloc(pSize->pRates, (pSize->nRates + 1) * sizeof(RRScreenRate)); + pNew = reallocarray(pSize->pRates, pSize->nRates + 1, sizeof(RRScreenRate)); if (!pNew) return FALSE; pRate = &pNew[pSize->nRates++]; diff --git a/randr/rrmode.c b/randr/rrmode.c index befac4741..a7aa43320 100644 --- a/randr/rrmode.c +++ b/randr/rrmode.c @@ -79,7 +79,7 @@ RRModeCreate(xRRModeInfo * modeInfo, const char *name, ScreenPtr userScreen) mode->userScreen = userScreen; if (num_modes) - newModes = realloc(modes, (num_modes + 1) * sizeof(RRModePtr)); + newModes = reallocarray(modes, num_modes + 1, sizeof(RRModePtr)); else newModes = malloc(sizeof(RRModePtr)); @@ -166,7 +166,7 @@ RRModesForScreen(ScreenPtr pScreen, int *num_ret) RRModePtr *screen_modes; int num_screen_modes = 0; - screen_modes = malloc((num_modes ? num_modes : 1) * sizeof(RRModePtr)); + screen_modes = xallocarray((num_modes ? num_modes : 1), sizeof(RRModePtr)); if (!screen_modes) return NULL; diff --git a/randr/rrmonitor.c b/randr/rrmonitor.c index fbdd352f6..c4bb617b1 100644 --- a/randr/rrmonitor.c +++ b/randr/rrmonitor.c @@ -494,8 +494,9 @@ RRMonitorAdd(ClientPtr client, ScreenPtr screen, RRMonitorPtr monitor) * needs to not have any side-effects on failure */ if (pScrPriv->numMonitors) - monitors = realloc(pScrPriv->monitors, - (pScrPriv->numMonitors + 1) * sizeof (RRMonitorPtr)); + monitors = reallocarray(pScrPriv->monitors, + pScrPriv->numMonitors + 1, + sizeof (RRMonitorPtr)); else monitors = malloc(sizeof (RRMonitorPtr)); diff --git a/randr/rroutput.c b/randr/rroutput.c index 548e07d1d..10df4da95 100644 --- a/randr/rroutput.c +++ b/randr/rroutput.c @@ -60,8 +60,8 @@ RROutputCreate(ScreenPtr pScreen, pScrPriv = rrGetScrPriv(pScreen); if (pScrPriv->numOutputs) - outputs = realloc(pScrPriv->outputs, - (pScrPriv->numOutputs + 1) * sizeof(RROutputPtr)); + outputs = reallocarray(pScrPriv->outputs, + pScrPriv->numOutputs + 1, sizeof(RROutputPtr)); else outputs = malloc(sizeof(RROutputPtr)); if (!outputs) @@ -124,7 +124,7 @@ RROutputSetClones(RROutputPtr output, RROutputPtr * clones, int numClones) return TRUE; } if (numClones) { - newClones = malloc(numClones * sizeof(RROutputPtr)); + newClones = xallocarray(numClones, sizeof(RROutputPtr)); if (!newClones) return FALSE; } @@ -157,7 +157,7 @@ RROutputSetModes(RROutputPtr output, } if (numModes) { - newModes = malloc(numModes * sizeof(RRModePtr)); + newModes = xallocarray(numModes, sizeof(RRModePtr)); if (!newModes) return FALSE; } @@ -200,8 +200,8 @@ RROutputAddUserMode(RROutputPtr output, RRModePtr mode) return BadMatch; if (output->userModes) - newModes = realloc(output->userModes, - (output->numUserModes + 1) * sizeof(RRModePtr)); + newModes = reallocarray(output->userModes, + output->numUserModes + 1, sizeof(RRModePtr)); else newModes = malloc(sizeof(RRModePtr)); if (!newModes) @@ -256,7 +256,7 @@ RROutputSetCrtcs(RROutputPtr output, RRCrtcPtr * crtcs, int numCrtcs) return TRUE; } if (numCrtcs) { - newCrtcs = malloc(numCrtcs * sizeof(RRCrtcPtr)); + newCrtcs = xallocarray(numCrtcs, sizeof(RRCrtcPtr)); if (!newCrtcs) return FALSE; } diff --git a/randr/rrproperty.c b/randr/rrproperty.c index e385e15ab..e56626cd2 100644 --- a/randr/rrproperty.c +++ b/randr/rrproperty.c @@ -140,7 +140,6 @@ RRChangeOutputProperty(RROutputPtr output, Atom property, Atom type, RRPropertyPtr prop; rrScrPrivPtr pScrPriv = rrGetScrPriv(output->pScreen); int size_in_bytes; - int total_size; unsigned long total_len; RRPropertyValuePtr prop_value; RRPropertyValueRec new_value; @@ -180,9 +179,8 @@ RRChangeOutputProperty(RROutputPtr output, Atom property, Atom type, if (mode == PropModeReplace || len > 0) { void *new_data = NULL, *old_data = NULL; - total_size = total_len * size_in_bytes; - new_value.data = (void *) malloc(total_size); - if (!new_value.data && total_size) { + new_value.data = xallocarray(total_len, size_in_bytes); + if (!new_value.data && total_len && size_in_bytes) { if (add) RRDestroyOutputProperty(prop); return BadAlloc; @@ -350,7 +348,7 @@ RRConfigureOutputProperty(RROutputPtr output, Atom property, return BadMatch; } - new_values = malloc(num_values * sizeof(INT32)); + new_values = xallocarray(num_values, sizeof(INT32)); if (!new_values && num_values) { if (add) RRDestroyOutputProperty(prop); @@ -400,7 +398,7 @@ ProcRRListOutputProperties(ClientPtr client) for (prop = output->properties; prop; prop = prop->next) numProps++; if (numProps) - if (!(pAtoms = (Atom *) malloc(numProps * sizeof(Atom)))) + if (!(pAtoms = xallocarray(numProps, sizeof(Atom)))) return BadAlloc; rep = (xRRListOutputPropertiesReply) { @@ -447,7 +445,7 @@ ProcRRQueryOutputProperty(ClientPtr client) return BadName; if (prop->num_valid) { - extra = malloc(prop->num_valid * sizeof(INT32)); + extra = xallocarray(prop->num_valid, sizeof(INT32)); if (!extra) return BadAlloc; } diff --git a/randr/rrproviderproperty.c b/randr/rrproviderproperty.c index ff2c614d0..b79c17f9b 100644 --- a/randr/rrproviderproperty.c +++ b/randr/rrproviderproperty.c @@ -350,7 +350,7 @@ RRConfigureProviderProperty(RRProviderPtr provider, Atom property, return BadMatch; } - new_values = malloc(num_values * sizeof(INT32)); + new_values = xallocarray(num_values, sizeof(INT32)); if (!new_values && num_values) { if (add) RRDestroyProviderProperty(prop); @@ -400,7 +400,7 @@ ProcRRListProviderProperties(ClientPtr client) for (prop = provider->properties; prop; prop = prop->next) numProps++; if (numProps) - if (!(pAtoms = (Atom *) malloc(numProps * sizeof(Atom)))) + if (!(pAtoms = xallocarray(numProps, sizeof(Atom)))) return BadAlloc; rep = (xRRListProviderPropertiesReply) { @@ -445,7 +445,7 @@ ProcRRQueryProviderProperty(ClientPtr client) return BadName; if (prop->num_valid) { - extra = malloc(prop->num_valid * sizeof(INT32)); + extra = xallocarray(prop->num_valid, sizeof(INT32)); if (!extra) return BadAlloc; } diff --git a/randr/rrtransform.c b/randr/rrtransform.c index c8a27498f..6137f8587 100644 --- a/randr/rrtransform.c +++ b/randr/rrtransform.c @@ -70,7 +70,7 @@ RRTransformSetFilter(RRTransformPtr dst, xFixed *new_params; if (nparams) { - new_params = malloc(nparams * sizeof(xFixed)); + new_params = xallocarray(nparams, sizeof(xFixed)); if (!new_params) return FALSE; memcpy(new_params, params, nparams * sizeof(xFixed)); |