summaryrefslogtreecommitdiff
path: root/Xext
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2015-03-21 13:42:12 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2015-04-21 16:57:08 -0700
commit1c56ac63c040280498c4a9d67b48c35b60070821 (patch)
treeab1073d348cb1acf0523ede3e1f2fa73f3b5fdb6 /Xext
parentb9e665c8b2f048feb3064ce412e0b3e9eb6797b0 (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 'Xext')
-rw-r--r--Xext/hashtable.c4
-rw-r--r--Xext/panoramiX.c10
-rw-r--r--Xext/panoramiXprocs.c19
-rw-r--r--Xext/saver.c2
-rw-r--r--Xext/shape.c2
-rw-r--r--Xext/sync.c4
-rw-r--r--Xext/xcmisc.c2
-rw-r--r--Xext/xf86bigfont.c4
-rw-r--r--Xext/xres.c2
-rw-r--r--Xext/xselinux_label.c2
-rw-r--r--Xext/xvmain.c2
11 files changed, 26 insertions, 27 deletions
diff --git a/Xext/hashtable.c b/Xext/hashtable.c
index 471ecca1c..41b2e0013 100644
--- a/Xext/hashtable.c
+++ b/Xext/hashtable.c
@@ -54,7 +54,7 @@ ht_create(int keySize,
ht->elements = 0;
ht->bucketBits = INITHASHSIZE;
numBuckets = 1 << ht->bucketBits;
- ht->buckets = malloc(numBuckets * sizeof(*ht->buckets));
+ ht->buckets = xallocarray(numBuckets, sizeof(*ht->buckets));
ht->cdata = cdata;
if (ht->buckets) {
@@ -92,7 +92,7 @@ double_size(HashTable ht)
int newNumBuckets = 1 << newBucketBits;
int c;
- newBuckets = malloc(newNumBuckets * sizeof(*ht->buckets));
+ newBuckets = xallocarray(newNumBuckets, sizeof(*ht->buckets));
if (newBuckets) {
for (c = 0; c < newNumBuckets; ++c) {
xorg_list_init(&newBuckets[c]);
diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index 2bbae2f5e..209df292c 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -747,13 +747,13 @@ PanoramiXMaybeAddDepth(DepthPtr pDepth)
j = PanoramiXNumDepths;
PanoramiXNumDepths++;
- PanoramiXDepths = realloc(PanoramiXDepths,
- PanoramiXNumDepths * sizeof(DepthRec));
+ PanoramiXDepths = reallocarray(PanoramiXDepths,
+ PanoramiXNumDepths, sizeof(DepthRec));
PanoramiXDepths[j].depth = pDepth->depth;
PanoramiXDepths[j].numVids = 0;
/* XXX suboptimal, should grow these dynamically */
if (pDepth->numVids)
- PanoramiXDepths[j].vids = malloc(sizeof(VisualID) * pDepth->numVids);
+ PanoramiXDepths[j].vids = xallocarray(pDepth->numVids, sizeof(VisualID));
else
PanoramiXDepths[j].vids = NULL;
}
@@ -789,8 +789,8 @@ PanoramiXMaybeAddVisual(VisualPtr pVisual)
/* found a matching visual on all screens, add it to the subset list */
j = PanoramiXNumVisuals;
PanoramiXNumVisuals++;
- PanoramiXVisuals = realloc(PanoramiXVisuals,
- PanoramiXNumVisuals * sizeof(VisualRec));
+ PanoramiXVisuals = reallocarray(PanoramiXVisuals,
+ PanoramiXNumVisuals, sizeof(VisualRec));
memcpy(&PanoramiXVisuals[j], pVisual, sizeof(VisualRec));
diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c
index 5291a4a4b..9eb29bd74 100644
--- a/Xext/panoramiXprocs.c
+++ b/Xext/panoramiXprocs.c
@@ -1341,7 +1341,7 @@ PanoramiXPolyPoint(ClientPtr client)
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyPointReq));
if (npoint > 0) {
- origPts = malloc(npoint * sizeof(xPoint));
+ origPts = xallocarray(npoint, sizeof(xPoint));
memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint));
FOR_NSCREENS_FORWARD(j) {
@@ -1406,7 +1406,7 @@ PanoramiXPolyLine(ClientPtr client)
isRoot = IS_ROOT_DRAWABLE(draw);
npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyLineReq));
if (npoint > 0) {
- origPts = malloc(npoint * sizeof(xPoint));
+ origPts = xallocarray(npoint, sizeof(xPoint));
memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint));
FOR_NSCREENS_FORWARD(j) {
@@ -1475,7 +1475,7 @@ PanoramiXPolySegment(ClientPtr client)
return BadLength;
nsegs >>= 3;
if (nsegs > 0) {
- origSegs = malloc(nsegs * sizeof(xSegment));
+ origSegs = xallocarray(nsegs, sizeof(xSegment));
memcpy((char *) origSegs, (char *) &stuff[1], nsegs * sizeof(xSegment));
FOR_NSCREENS_FORWARD(j) {
@@ -1543,7 +1543,7 @@ PanoramiXPolyRectangle(ClientPtr client)
return BadLength;
nrects >>= 3;
if (nrects > 0) {
- origRecs = malloc(nrects * sizeof(xRectangle));
+ origRecs = xallocarray(nrects, sizeof(xRectangle));
memcpy((char *) origRecs, (char *) &stuff[1],
nrects * sizeof(xRectangle));
FOR_NSCREENS_FORWARD(j) {
@@ -1610,7 +1610,7 @@ PanoramiXPolyArc(ClientPtr client)
return BadLength;
narcs /= sizeof(xArc);
if (narcs > 0) {
- origArcs = malloc(narcs * sizeof(xArc));
+ origArcs = xallocarray(narcs, sizeof(xArc));
memcpy((char *) origArcs, (char *) &stuff[1], narcs * sizeof(xArc));
FOR_NSCREENS_FORWARD(j) {
@@ -1672,7 +1672,7 @@ PanoramiXFillPoly(ClientPtr client)
count = bytes_to_int32((client->req_len << 2) - sizeof(xFillPolyReq));
if (count > 0) {
- locPts = malloc(count * sizeof(DDXPointRec));
+ locPts = xallocarray(count, sizeof(DDXPointRec));
memcpy((char *) locPts, (char *) &stuff[1],
count * sizeof(DDXPointRec));
FOR_NSCREENS_FORWARD(j) {
@@ -1741,7 +1741,7 @@ PanoramiXPolyFillRectangle(ClientPtr client)
return BadLength;
things >>= 3;
if (things > 0) {
- origRects = malloc(things * sizeof(xRectangle));
+ origRects = xallocarray(things, sizeof(xRectangle));
memcpy((char *) origRects, (char *) &stuff[1],
things * sizeof(xRectangle));
FOR_NSCREENS_FORWARD(j) {
@@ -1808,7 +1808,7 @@ PanoramiXPolyFillArc(ClientPtr client)
return BadLength;
narcs /= sizeof(xArc);
if (narcs > 0) {
- origArcs = malloc(narcs * sizeof(xArc));
+ origArcs = xallocarray(narcs, sizeof(xArc));
memcpy((char *) origArcs, (char *) &stuff[1], narcs * sizeof(xArc));
FOR_NSCREENS_FORWARD(j) {
@@ -1988,8 +1988,7 @@ PanoramiXGetImage(ClientPtr client)
if (linesPerBuf > h)
linesPerBuf = h;
}
- length = linesPerBuf * widthBytesLine;
- if (!(pBuf = malloc(length)))
+ if (!(pBuf = xallocarray(linesPerBuf, widthBytesLine)))
return BadAlloc;
WriteReplyToClient(client, sizeof(xGetImageReply), &xgi);
diff --git a/Xext/saver.c b/Xext/saver.c
index 2c14ea00e..0e20467c9 100644
--- a/Xext/saver.c
+++ b/Xext/saver.c
@@ -853,7 +853,7 @@ ScreenSaverSetAttributes(ClientPtr client)
goto bail;
}
/* over allocate for override redirect */
- pAttr->values = values = malloc((len + 1) * sizeof(unsigned long));
+ pAttr->values = values = xallocarray(len + 1, sizeof(unsigned long));
if (!values) {
ret = BadAlloc;
goto bail;
diff --git a/Xext/shape.c b/Xext/shape.c
index bb479b159..2fc789ec1 100644
--- a/Xext/shape.c
+++ b/Xext/shape.c
@@ -996,7 +996,7 @@ ProcShapeGetRectangles(ClientPtr client)
nrects = RegionNumRects(region);
box = RegionRects(region);
- rects = malloc(nrects * sizeof(xRectangle));
+ rects = xallocarray(nrects, sizeof(xRectangle));
if (!rects && nrects)
return BadAlloc;
for (i = 0; i < nrects; i++, box++) {
diff --git a/Xext/sync.c b/Xext/sync.c
index ba08cd1bb..41405619c 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -620,7 +620,7 @@ SyncAwaitTriggerFired(SyncTrigger * pTrigger)
pAwaitUnion = (SyncAwaitUnion *) pAwait->pHeader;
numwaits = pAwaitUnion->header.num_waitconditions;
- ppAwait = malloc(numwaits * sizeof(SyncAwait *));
+ ppAwait = xallocarray(numwaits, sizeof(SyncAwait *));
if (!ppAwait)
goto bail;
@@ -1514,7 +1514,7 @@ SyncAwaitPrologue(ClientPtr client, int items)
/* all the memory for the entire await list is allocated
* here in one chunk
*/
- pAwaitUnion = malloc((items + 1) * sizeof(SyncAwaitUnion));
+ pAwaitUnion = xallocarray(items + 1, sizeof(SyncAwaitUnion));
if (!pAwaitUnion)
return NULL;
diff --git a/Xext/xcmisc.c b/Xext/xcmisc.c
index 1e9101059..ed25650cd 100644
--- a/Xext/xcmisc.c
+++ b/Xext/xcmisc.c
@@ -101,7 +101,7 @@ ProcXCMiscGetXIDList(ClientPtr client)
if (stuff->count > UINT32_MAX / sizeof(XID))
return BadAlloc;
- pids = (XID *) malloc(stuff->count * sizeof(XID));
+ pids = xallocarray(stuff->count, sizeof(XID));
if (!pids) {
return BadAlloc;
}
diff --git a/Xext/xf86bigfont.c b/Xext/xf86bigfont.c
index 46b3242d1..95b537170 100644
--- a/Xext/xf86bigfont.c
+++ b/Xext/xf86bigfont.c
@@ -401,7 +401,7 @@ ProcXF86BigfontQueryFont(ClientPtr client)
}
else {
#endif
- pCI = malloc(nCharInfos * sizeof(xCharInfo));
+ pCI = xallocarray(nCharInfos, sizeof(xCharInfo));
if (!pCI)
return BadAlloc;
#ifdef HAS_SHM
@@ -463,7 +463,7 @@ ProcXF86BigfontQueryFont(ClientPtr client)
if (hashModulus > nCharInfos + 1)
hashModulus = nCharInfos + 1;
- tmp = malloc((4 * nCharInfos + 1) * sizeof(CARD16));
+ tmp = xallocarray(4 * nCharInfos + 1, sizeof(CARD16));
if (!tmp) {
if (!pDesc)
free(pCI);
diff --git a/Xext/xres.c b/Xext/xres.c
index 273793806..6b87c3ddc 100644
--- a/Xext/xres.c
+++ b/Xext/xres.c
@@ -223,7 +223,7 @@ ProcXResQueryClients(ClientPtr client)
REQUEST_SIZE_MATCH(xXResQueryClientsReq);
- current_clients = malloc(currentMaxClients * sizeof(int));
+ current_clients = xallocarray(currentMaxClients, sizeof(int));
num_clients = 0;
for (i = 0; i < currentMaxClients; i++) {
diff --git a/Xext/xselinux_label.c b/Xext/xselinux_label.c
index 2c33d1cbf..8559385b9 100644
--- a/Xext/xselinux_label.c
+++ b/Xext/xselinux_label.c
@@ -64,7 +64,7 @@ SELinuxArraySet(SELinuxArrayRec * rec, unsigned key, void *val)
{
if (key >= rec->size) {
/* Need to increase size of array */
- rec->array = realloc(rec->array, (key + 1) * sizeof(val));
+ rec->array = reallocarray(rec->array, key + 1, sizeof(val));
if (!rec->array)
return FALSE;
memset(rec->array + rec->size, 0, (key - rec->size + 1) * sizeof(val));
diff --git a/Xext/xvmain.c b/Xext/xvmain.c
index 0abf190dc..93e5f0cd3 100644
--- a/Xext/xvmain.c
+++ b/Xext/xvmain.c
@@ -1102,7 +1102,7 @@ XvFillColorKey(DrawablePtr pDraw, CARD32 key, RegionPtr region)
(void) ChangeGC(NullClient, gc, GCForeground | GCSubwindowMode, pval);
ValidateGC(pDraw, gc);
- rects = malloc(nbox * sizeof(xRectangle));
+ rects = xallocarray(nbox, sizeof(xRectangle));
if (rects) {
for (i = 0; i < nbox; i++, pbox++) {
rects[i].x = pbox->x1 - pDraw->x;