Convert dix/* 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>
This commit is contained in:
parent
df4e41fdb4
commit
b9e665c8b2
|
@ -119,7 +119,7 @@ MakeAtom(const char *string, unsigned len, Bool makeit)
|
|||
if ((lastAtom + 1) >= tableLength) {
|
||||
NodePtr *table;
|
||||
|
||||
table = realloc(nodeTable, tableLength * (2 * sizeof(NodePtr)));
|
||||
table = reallocarray(nodeTable, tableLength, 2 * sizeof(NodePtr));
|
||||
if (!table) {
|
||||
if (nd->string != string) {
|
||||
/* nd->string has been strdup'ed */
|
||||
|
@ -200,7 +200,7 @@ InitAtoms(void)
|
|||
{
|
||||
FreeAllAtoms();
|
||||
tableLength = InitialTableSize;
|
||||
nodeTable = malloc(InitialTableSize * sizeof(NodePtr));
|
||||
nodeTable = xallocarray(InitialTableSize, sizeof(NodePtr));
|
||||
if (!nodeTable)
|
||||
AtomError();
|
||||
nodeTable[None] = NULL;
|
||||
|
|
|
@ -296,7 +296,7 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
|
|||
for (pent = &pmap->red[size - 1]; pent >= pmap->red; pent--)
|
||||
pent->refcnt = AllocPrivate;
|
||||
pmap->freeRed = 0;
|
||||
ppix = malloc(size * sizeof(Pixel));
|
||||
ppix = xallocarray(size, sizeof(Pixel));
|
||||
if (!ppix) {
|
||||
free(pmap);
|
||||
return BadAlloc;
|
||||
|
@ -337,7 +337,7 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
|
|||
for (pent = &pmap->green[size - 1]; pent >= pmap->green; pent--)
|
||||
pent->refcnt = AllocPrivate;
|
||||
pmap->freeGreen = 0;
|
||||
ppix = malloc(size * sizeof(Pixel));
|
||||
ppix = xallocarray(size, sizeof(Pixel));
|
||||
if (!ppix) {
|
||||
free(pmap->clientPixelsRed[client]);
|
||||
free(pmap);
|
||||
|
@ -352,7 +352,7 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
|
|||
for (pent = &pmap->blue[size - 1]; pent >= pmap->blue; pent--)
|
||||
pent->refcnt = AllocPrivate;
|
||||
pmap->freeBlue = 0;
|
||||
ppix = malloc(size * sizeof(Pixel));
|
||||
ppix = xallocarray(size, sizeof(Pixel));
|
||||
if (!ppix) {
|
||||
free(pmap->clientPixelsGreen[client]);
|
||||
free(pmap->clientPixelsRed[client]);
|
||||
|
@ -702,7 +702,7 @@ UpdateColors(ColormapPtr pmap)
|
|||
|
||||
pVisual = pmap->pVisual;
|
||||
size = pVisual->ColormapEntries;
|
||||
defs = malloc(size * sizeof(xColorItem));
|
||||
defs = xallocarray(size, sizeof(xColorItem));
|
||||
if (!defs)
|
||||
return;
|
||||
n = 0;
|
||||
|
@ -792,8 +792,8 @@ AllocColor(ColormapPtr pmap,
|
|||
*pgreen = pmap->red[pixR].co.local.green;
|
||||
*pblue = pmap->red[pixR].co.local.blue;
|
||||
npix = pmap->numPixelsRed[client];
|
||||
ppix = (Pixel *) realloc(pmap->clientPixelsRed[client],
|
||||
(npix + 1) * sizeof(Pixel));
|
||||
ppix = reallocarray(pmap->clientPixelsRed[client],
|
||||
npix + 1, sizeof(Pixel));
|
||||
if (!ppix)
|
||||
return BadAlloc;
|
||||
ppix[npix] = pixR;
|
||||
|
@ -814,22 +814,22 @@ AllocColor(ColormapPtr pmap,
|
|||
*pgreen = pmap->green[pixG].co.local.green;
|
||||
*pblue = pmap->blue[pixB].co.local.blue;
|
||||
npix = pmap->numPixelsRed[client];
|
||||
ppix = (Pixel *) realloc(pmap->clientPixelsRed[client],
|
||||
(npix + 1) * sizeof(Pixel));
|
||||
ppix = reallocarray(pmap->clientPixelsRed[client],
|
||||
npix + 1, sizeof(Pixel));
|
||||
if (!ppix)
|
||||
return BadAlloc;
|
||||
ppix[npix] = pixR;
|
||||
pmap->clientPixelsRed[client] = ppix;
|
||||
npix = pmap->numPixelsGreen[client];
|
||||
ppix = (Pixel *) realloc(pmap->clientPixelsGreen[client],
|
||||
(npix + 1) * sizeof(Pixel));
|
||||
ppix = reallocarray(pmap->clientPixelsGreen[client],
|
||||
npix + 1, sizeof(Pixel));
|
||||
if (!ppix)
|
||||
return BadAlloc;
|
||||
ppix[npix] = pixG;
|
||||
pmap->clientPixelsGreen[client] = ppix;
|
||||
npix = pmap->numPixelsBlue[client];
|
||||
ppix = (Pixel *) realloc(pmap->clientPixelsBlue[client],
|
||||
(npix + 1) * sizeof(Pixel));
|
||||
ppix = reallocarray(pmap->clientPixelsBlue[client],
|
||||
npix + 1, sizeof(Pixel));
|
||||
if (!ppix)
|
||||
return BadAlloc;
|
||||
ppix[npix] = pixB;
|
||||
|
@ -1279,7 +1279,7 @@ FindColor(ColormapPtr pmap, EntryPtr pentFirst, int size, xrgb * prgb,
|
|||
break;
|
||||
}
|
||||
npix = nump[client];
|
||||
ppix = (Pixel *) realloc(pixp[client], (npix + 1) * sizeof(Pixel));
|
||||
ppix = reallocarray(pixp[client], npix + 1, sizeof(Pixel));
|
||||
if (!ppix) {
|
||||
pent->refcnt--;
|
||||
if (!pent->fShared)
|
||||
|
@ -1647,9 +1647,9 @@ AllocDirect(int client, ColormapPtr pmap, int c, int r, int g, int b,
|
|||
for (p = pixels; p < pixels + c; p++)
|
||||
*p = 0;
|
||||
|
||||
ppixRed = malloc(npixR * sizeof(Pixel));
|
||||
ppixGreen = malloc(npixG * sizeof(Pixel));
|
||||
ppixBlue = malloc(npixB * sizeof(Pixel));
|
||||
ppixRed = xallocarray(npixR, sizeof(Pixel));
|
||||
ppixGreen = xallocarray(npixG, sizeof(Pixel));
|
||||
ppixBlue = xallocarray(npixB, sizeof(Pixel));
|
||||
if (!ppixRed || !ppixGreen || !ppixBlue) {
|
||||
free(ppixBlue);
|
||||
free(ppixGreen);
|
||||
|
@ -1662,19 +1662,19 @@ AllocDirect(int client, ColormapPtr pmap, int c, int r, int g, int b,
|
|||
okB = AllocCP(pmap, pmap->blue, c, b, contig, ppixBlue, pbmask);
|
||||
|
||||
if (okR && okG && okB) {
|
||||
rpix = (Pixel *) realloc(pmap->clientPixelsRed[client],
|
||||
(pmap->numPixelsRed[client] + (c << r)) *
|
||||
sizeof(Pixel));
|
||||
rpix = reallocarray(pmap->clientPixelsRed[client],
|
||||
pmap->numPixelsRed[client] + (c << r),
|
||||
sizeof(Pixel));
|
||||
if (rpix)
|
||||
pmap->clientPixelsRed[client] = rpix;
|
||||
gpix = (Pixel *) realloc(pmap->clientPixelsGreen[client],
|
||||
(pmap->numPixelsGreen[client] + (c << g)) *
|
||||
sizeof(Pixel));
|
||||
gpix = reallocarray(pmap->clientPixelsGreen[client],
|
||||
pmap->numPixelsGreen[client] + (c << g),
|
||||
sizeof(Pixel));
|
||||
if (gpix)
|
||||
pmap->clientPixelsGreen[client] = gpix;
|
||||
bpix = (Pixel *) realloc(pmap->clientPixelsBlue[client],
|
||||
(pmap->numPixelsBlue[client] + (c << b)) *
|
||||
sizeof(Pixel));
|
||||
bpix = reallocarray(pmap->clientPixelsBlue[client],
|
||||
pmap->numPixelsBlue[client] + (c << b),
|
||||
sizeof(Pixel));
|
||||
if (bpix)
|
||||
pmap->clientPixelsBlue[client] = bpix;
|
||||
}
|
||||
|
@ -1747,7 +1747,7 @@ AllocPseudo(int client, ColormapPtr pmap, int c, int r, Bool contig,
|
|||
npix = c << r;
|
||||
if ((r >= 32) || (npix > pmap->freeRed) || (npix < c))
|
||||
return BadAlloc;
|
||||
if (!(ppixTemp = malloc(npix * sizeof(Pixel))))
|
||||
if (!(ppixTemp = xallocarray(npix, sizeof(Pixel))))
|
||||
return BadAlloc;
|
||||
ok = AllocCP(pmap, pmap->red, c, r, contig, ppixTemp, pmask);
|
||||
|
||||
|
@ -1755,9 +1755,8 @@ AllocPseudo(int client, ColormapPtr pmap, int c, int r, Bool contig,
|
|||
|
||||
/* all the allocated pixels are added to the client pixel list,
|
||||
* but only the unique ones are returned to the client */
|
||||
ppix = (Pixel *) realloc(pmap->clientPixelsRed[client],
|
||||
(pmap->numPixelsRed[client] +
|
||||
npix) * sizeof(Pixel));
|
||||
ppix = reallocarray(pmap->clientPixelsRed[client],
|
||||
pmap->numPixelsRed[client] + npix, sizeof(Pixel));
|
||||
if (!ppix) {
|
||||
for (p = ppixTemp; p < ppixTemp + npix; p++)
|
||||
pmap->red[*p].refcnt = 0;
|
||||
|
@ -1960,7 +1959,7 @@ AllocShared(ColormapPtr pmap, Pixel * ppix, int c, int r, int g, int b,
|
|||
|
||||
npixClientNew = c << (r + g + b);
|
||||
npixShared = (c << r) + (c << g) + (c << b);
|
||||
psharedList = malloc(npixShared * sizeof(SHAREDCOLOR *));
|
||||
psharedList = xallocarray(npixShared, sizeof(SHAREDCOLOR *));
|
||||
if (!psharedList)
|
||||
return FALSE;
|
||||
ppshared = psharedList;
|
||||
|
@ -2204,7 +2203,7 @@ FreeCo(ColormapPtr pmap, int client, int color, int npixIn, Pixel * ppixIn,
|
|||
npix++;
|
||||
}
|
||||
}
|
||||
pptr = (Pixel *) realloc(ppixClient, npixNew * sizeof(Pixel));
|
||||
pptr = reallocarray(ppixClient, npixNew, sizeof(Pixel));
|
||||
if (pptr)
|
||||
ppixClient = pptr;
|
||||
npixClient = npixNew;
|
||||
|
@ -2469,8 +2468,8 @@ IsMapInstalled(Colormap map, WindowPtr pWin)
|
|||
Colormap *pmaps;
|
||||
int imap, nummaps, found;
|
||||
|
||||
pmaps =
|
||||
malloc(pWin->drawable.pScreen->maxInstalledCmaps * sizeof(Colormap));
|
||||
pmaps = xallocarray(pWin->drawable.pScreen->maxInstalledCmaps,
|
||||
sizeof(Colormap));
|
||||
if (!pmaps)
|
||||
return FALSE;
|
||||
nummaps = (*pWin->drawable.pScreen->ListInstalledColormaps)
|
||||
|
@ -2521,8 +2520,8 @@ ResizeVisualArray(ScreenPtr pScreen, int new_visual_count, DepthPtr depth)
|
|||
first_new_vid = depth->numVids;
|
||||
first_new_visual = pScreen->numVisuals;
|
||||
|
||||
vids =
|
||||
realloc(depth->vids, (depth->numVids + new_visual_count) * sizeof(XID));
|
||||
vids = reallocarray(depth->vids, depth->numVids + new_visual_count,
|
||||
sizeof(XID));
|
||||
if (!vids)
|
||||
return FALSE;
|
||||
|
||||
|
@ -2530,7 +2529,7 @@ ResizeVisualArray(ScreenPtr pScreen, int new_visual_count, DepthPtr depth)
|
|||
depth->vids = vids;
|
||||
|
||||
numVisuals = pScreen->numVisuals + new_visual_count;
|
||||
visuals = realloc(pScreen->visuals, numVisuals * sizeof(VisualRec));
|
||||
visuals = reallocarray(pScreen->visuals, numVisuals, sizeof(VisualRec));
|
||||
if (!visuals) {
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -1469,8 +1469,8 @@ InitStringFeedbackClassDeviceStruct(DeviceIntPtr dev,
|
|||
feedc->ctrl.num_symbols_displayed = 0;
|
||||
feedc->ctrl.max_symbols = max_symbols;
|
||||
feedc->ctrl.symbols_supported =
|
||||
malloc(sizeof(KeySym) * num_symbols_supported);
|
||||
feedc->ctrl.symbols_displayed = malloc(sizeof(KeySym) * max_symbols);
|
||||
xallocarray(num_symbols_supported, sizeof(KeySym));
|
||||
feedc->ctrl.symbols_displayed = xallocarray(max_symbols, sizeof(KeySym));
|
||||
if (!feedc->ctrl.symbols_supported || !feedc->ctrl.symbols_displayed) {
|
||||
free(feedc->ctrl.symbols_supported);
|
||||
free(feedc->ctrl.symbols_displayed);
|
||||
|
|
|
@ -344,7 +344,7 @@ Dispatch(void)
|
|||
nextFreeClientID = 1;
|
||||
nClients = 0;
|
||||
|
||||
clientReady = malloc(sizeof(int) * MaxClients);
|
||||
clientReady = xallocarray(MaxClients, sizeof(int));
|
||||
if (!clientReady)
|
||||
return;
|
||||
|
||||
|
@ -963,7 +963,7 @@ ProcQueryTree(ClientPtr client)
|
|||
if (numChildren) {
|
||||
int curChild = 0;
|
||||
|
||||
childIDs = malloc(numChildren * sizeof(Window));
|
||||
childIDs = xallocarray(numChildren, sizeof(Window));
|
||||
if (!childIDs)
|
||||
return BadAlloc;
|
||||
for (pChild = pWin->lastChild; pChild != pHead;
|
||||
|
|
|
@ -168,9 +168,8 @@ QueueFontWakeup(FontPathElementPtr fpe)
|
|||
}
|
||||
}
|
||||
if (num_slept_fpes == size_slept_fpes) {
|
||||
new = (FontPathElementPtr *)
|
||||
realloc(slept_fpes,
|
||||
sizeof(FontPathElementPtr) * (size_slept_fpes + 4));
|
||||
new = reallocarray(slept_fpes, size_slept_fpes + 4,
|
||||
sizeof(FontPathElementPtr));
|
||||
if (!new)
|
||||
return;
|
||||
slept_fpes = new;
|
||||
|
@ -424,7 +423,7 @@ OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname,
|
|||
* copy the current FPE list, so that if it gets changed by another client
|
||||
* while we're blocking, the request still appears atomic
|
||||
*/
|
||||
c->fpe_list = malloc(sizeof(FontPathElementPtr) * num_fpes);
|
||||
c->fpe_list = xallocarray(num_fpes, sizeof(FontPathElementPtr));
|
||||
if (!c->fpe_list) {
|
||||
free((void *) c->fontname);
|
||||
free(c);
|
||||
|
@ -821,7 +820,7 @@ ListFonts(ClientPtr client, unsigned char *pattern, unsigned length,
|
|||
|
||||
if (!(c = malloc(sizeof *c)))
|
||||
return BadAlloc;
|
||||
c->fpe_list = malloc(sizeof(FontPathElementPtr) * num_fpes);
|
||||
c->fpe_list = xallocarray(num_fpes, sizeof(FontPathElementPtr));
|
||||
if (!c->fpe_list) {
|
||||
free(c);
|
||||
return BadAlloc;
|
||||
|
@ -1072,7 +1071,7 @@ StartListFontsWithInfo(ClientPtr client, int length, unsigned char *pattern,
|
|||
|
||||
if (!(c = malloc(sizeof *c)))
|
||||
goto badAlloc;
|
||||
c->fpe_list = malloc(sizeof(FontPathElementPtr) * num_fpes);
|
||||
c->fpe_list = xallocarray(num_fpes, sizeof(FontPathElementPtr));
|
||||
if (!c->fpe_list) {
|
||||
free(c);
|
||||
goto badAlloc;
|
||||
|
@ -1441,7 +1440,7 @@ doImageText(ClientPtr client, ITclosurePtr c)
|
|||
*new_closure = *c;
|
||||
c = new_closure;
|
||||
|
||||
data = malloc(c->nChars * itemSize);
|
||||
data = xallocarray(c->nChars, itemSize);
|
||||
if (!data) {
|
||||
free(c);
|
||||
c = old_closure;
|
||||
|
@ -1597,7 +1596,7 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist)
|
|||
unsigned char *cp = paths;
|
||||
FontPathElementPtr fpe = NULL, *fplist;
|
||||
|
||||
fplist = malloc(sizeof(FontPathElementPtr) * npaths);
|
||||
fplist = xallocarray(npaths, sizeof(FontPathElementPtr));
|
||||
if (!fplist) {
|
||||
*bad = 0;
|
||||
return BadAlloc;
|
||||
|
@ -1894,8 +1893,7 @@ RegisterFPEFunctions(NameCheckFunc name_func,
|
|||
FPEFunctions *new;
|
||||
|
||||
/* grow the list */
|
||||
new = (FPEFunctions *) realloc(fpe_functions,
|
||||
(num_fpe_types + 1) * sizeof(FPEFunctions));
|
||||
new = reallocarray(fpe_functions, num_fpe_types + 1, sizeof(FPEFunctions));
|
||||
if (!new)
|
||||
return -1;
|
||||
fpe_functions = new;
|
||||
|
|
|
@ -714,7 +714,7 @@ DeliverStateNotifyEvent(DeviceIntPtr dev, WindowPtr win)
|
|||
}
|
||||
}
|
||||
|
||||
sev = ev = (deviceStateNotify *) malloc(evcount * sizeof(xEvent));
|
||||
sev = ev = xallocarray(evcount, sizeof(xEvent));
|
||||
FixDeviceStateNotify(dev, ev, NULL, NULL, NULL, first);
|
||||
|
||||
if (b != NULL) {
|
||||
|
|
|
@ -4785,8 +4785,8 @@ SetInputFocus(ClientPtr client,
|
|||
depth++;
|
||||
if (depth > focus->traceSize) {
|
||||
focus->traceSize = depth + 1;
|
||||
focus->trace = realloc(focus->trace,
|
||||
focus->traceSize * sizeof(WindowPtr));
|
||||
focus->trace = reallocarray(focus->trace, focus->traceSize,
|
||||
sizeof(WindowPtr));
|
||||
}
|
||||
focus->traceGood = depth;
|
||||
for (pWin = focusWin, depth--; pWin; pWin = pWin->parent, depth--)
|
||||
|
|
|
@ -103,8 +103,7 @@ AddExtension(const char *name, int NumEvents, int NumErrors,
|
|||
return ((ExtensionEntry *) NULL);
|
||||
}
|
||||
i = NumExtensions;
|
||||
newexts = (ExtensionEntry **) realloc(extensions,
|
||||
(i + 1) * sizeof(ExtensionEntry *));
|
||||
newexts = reallocarray(extensions, i + 1, sizeof(ExtensionEntry *));
|
||||
if (!newexts) {
|
||||
free((void *) ext->name);
|
||||
dixFreePrivates(ext->devPrivates, PRIVATE_EXTENSION);
|
||||
|
@ -153,8 +152,7 @@ AddExtensionAlias(const char *alias, ExtensionEntry * ext)
|
|||
|
||||
if (!ext)
|
||||
return FALSE;
|
||||
aliases = realloc(ext->aliases,
|
||||
(ext->num_aliases + 1) * sizeof(char *));
|
||||
aliases = reallocarray(ext->aliases, ext->num_aliases + 1, sizeof(char *));
|
||||
if (!aliases)
|
||||
return FALSE;
|
||||
ext->aliases = aliases;
|
||||
|
|
|
@ -594,10 +594,10 @@ DeletePassiveGrabFromList(GrabPtr pMinuendGrab)
|
|||
i++;
|
||||
if (!i)
|
||||
return TRUE;
|
||||
deletes = malloc(i * sizeof(GrabPtr));
|
||||
adds = malloc(i * sizeof(GrabPtr));
|
||||
updates = malloc(i * sizeof(Mask **));
|
||||
details = malloc(i * sizeof(Mask *));
|
||||
deletes = xallocarray(i, sizeof(GrabPtr));
|
||||
adds = xallocarray(i, sizeof(GrabPtr));
|
||||
updates = xallocarray(i, sizeof(Mask **));
|
||||
details = xallocarray(i, sizeof(Mask *));
|
||||
if (!deletes || !adds || !updates || !details) {
|
||||
free(details);
|
||||
free(updates);
|
||||
|
|
|
@ -136,8 +136,8 @@ ProcRotateProperties(ClientPtr client)
|
|||
return rc;
|
||||
|
||||
atoms = (Atom *) &stuff[1];
|
||||
props = malloc(stuff->nAtoms * sizeof(PropertyPtr));
|
||||
saved = malloc(stuff->nAtoms * sizeof(PropertyRec));
|
||||
props = xallocarray(stuff->nAtoms, sizeof(PropertyPtr));
|
||||
saved = xallocarray(stuff->nAtoms, sizeof(PropertyRec));
|
||||
if (!props || !saved) {
|
||||
rc = BadAlloc;
|
||||
goto out;
|
||||
|
@ -313,7 +313,7 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property,
|
|||
/* do nothing */
|
||||
}
|
||||
else if (mode == PropModeAppend) {
|
||||
data = malloc((pProp->size + len) * sizeInBytes);
|
||||
data = xallocarray(pProp->size + len, sizeInBytes);
|
||||
if (!data)
|
||||
return BadAlloc;
|
||||
memcpy(data, pProp->data, pProp->size * sizeInBytes);
|
||||
|
@ -322,7 +322,7 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property,
|
|||
pProp->size += len;
|
||||
}
|
||||
else if (mode == PropModePrepend) {
|
||||
data = malloc(sizeInBytes * (len + pProp->size));
|
||||
data = xallocarray(len + pProp->size, sizeInBytes);
|
||||
if (!data)
|
||||
return BadAlloc;
|
||||
memcpy(data + totalSize, pProp->data, pProp->size * sizeInBytes);
|
||||
|
@ -581,7 +581,7 @@ ProcListProperties(ClientPtr client)
|
|||
for (pProp = wUserProps(pWin); pProp; pProp = pProp->next)
|
||||
numProps++;
|
||||
|
||||
if (numProps && !(pAtoms = malloc(numProps * sizeof(Atom))))
|
||||
if (numProps && !(pAtoms = xallocarray(numProps, sizeof(Atom))))
|
||||
return BadAlloc;
|
||||
|
||||
numProps = 0;
|
||||
|
|
|
@ -1247,7 +1247,7 @@ RegionValidate(RegionPtr badreg, Bool *pOverlap)
|
|||
if (sizeRI == numRI) {
|
||||
/* Oops, allocate space for new region information */
|
||||
sizeRI <<= 1;
|
||||
rit = (RegionInfo *) realloc(ri, sizeRI * sizeof(RegionInfo));
|
||||
rit = (RegionInfo *) reallocarray(ri, sizeRI, sizeof(RegionInfo));
|
||||
if (!rit)
|
||||
goto bail;
|
||||
ri = rit;
|
||||
|
|
|
@ -510,7 +510,7 @@ CreateNewResourceType(DeleteType deleteFunc, const char *name)
|
|||
|
||||
if (next & lastResourceClass)
|
||||
return 0;
|
||||
types = realloc(resourceTypes, (next + 1) * sizeof(*resourceTypes));
|
||||
types = reallocarray(resourceTypes, next + 1, sizeof(*resourceTypes));
|
||||
if (!types)
|
||||
return 0;
|
||||
|
||||
|
@ -834,10 +834,10 @@ RebuildTable(int client)
|
|||
*/
|
||||
|
||||
j = 2 * clientTable[client].buckets;
|
||||
tails = malloc(j * sizeof(ResourcePtr *));
|
||||
tails = xallocarray(j, sizeof(ResourcePtr *));
|
||||
if (!tails)
|
||||
return;
|
||||
resources = malloc(j * sizeof(ResourcePtr));
|
||||
resources = xallocarray(j, sizeof(ResourcePtr));
|
||||
if (!resources) {
|
||||
free(tails);
|
||||
return;
|
||||
|
|
|
@ -101,7 +101,7 @@ TouchResizeQueue(ClientPtr client, void *closure)
|
|||
* don't need to do it often */
|
||||
size = dev->last.num_touches + dev->last.num_touches / 2 + 1;
|
||||
|
||||
tmp = realloc(dev->last.touches, size * sizeof(*dev->last.touches));
|
||||
tmp = reallocarray(dev->last.touches, size, sizeof(*dev->last.touches));
|
||||
if (tmp) {
|
||||
int j;
|
||||
|
||||
|
@ -350,7 +350,7 @@ TouchBeginTouch(DeviceIntPtr dev, int sourceid, uint32_t touchid,
|
|||
|
||||
/* If we get here, then we've run out of touches: enlarge dev->touch and
|
||||
* try again. */
|
||||
tmp = realloc(t->touches, (t->num_touches + 1) * sizeof(*ti));
|
||||
tmp = reallocarray(t->touches, t->num_touches + 1, sizeof(*ti));
|
||||
if (tmp) {
|
||||
t->touches = tmp;
|
||||
t->num_touches++;
|
||||
|
@ -547,8 +547,8 @@ TouchBuildDependentSpriteTrace(DeviceIntPtr dev, SpritePtr sprite)
|
|||
return FALSE;
|
||||
|
||||
if (srcsprite->spriteTraceGood > sprite->spriteTraceSize) {
|
||||
trace = realloc(sprite->spriteTrace,
|
||||
srcsprite->spriteTraceSize * sizeof(*trace));
|
||||
trace = reallocarray(sprite->spriteTrace,
|
||||
srcsprite->spriteTraceSize, sizeof(*trace));
|
||||
if (!trace) {
|
||||
sprite->spriteTraceGood = 0;
|
||||
return FALSE;
|
||||
|
|
Loading…
Reference in New Issue