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