Convert hw/xnest & hw/vfb to new *allocarray functions
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Matt Turner <mattst88@gmail.com>
This commit is contained in:
parent
4cb1034906
commit
ae2dc01cf1
|
@ -292,7 +292,7 @@ ddxProcessArgument(int argc, char *argv[], int i)
|
||||||
|
|
||||||
if (vfbNumScreens <= screenNum) {
|
if (vfbNumScreens <= screenNum) {
|
||||||
vfbScreens =
|
vfbScreens =
|
||||||
realloc(vfbScreens, sizeof(*vfbScreens) * (screenNum + 1));
|
reallocarray(vfbScreens, screenNum + 1, sizeof(*vfbScreens));
|
||||||
if (!vfbScreens)
|
if (!vfbScreens)
|
||||||
FatalError("Not enough memory for screen %d\n", screenNum);
|
FatalError("Not enough memory for screen %d\n", screenNum);
|
||||||
for (; vfbNumScreens <= screenNum; ++vfbNumScreens)
|
for (; vfbNumScreens <= screenNum; ++vfbNumScreens)
|
||||||
|
@ -407,9 +407,9 @@ vfbInstallColormap(ColormapPtr pmap)
|
||||||
swapcopy32(pXWDHeader->bits_per_rgb, pVisual->bitsPerRGBValue);
|
swapcopy32(pXWDHeader->bits_per_rgb, pVisual->bitsPerRGBValue);
|
||||||
swapcopy32(pXWDHeader->colormap_entries, pVisual->ColormapEntries);
|
swapcopy32(pXWDHeader->colormap_entries, pVisual->ColormapEntries);
|
||||||
|
|
||||||
ppix = (Pixel *) malloc(entries * sizeof(Pixel));
|
ppix = xallocarray(entries, sizeof(Pixel));
|
||||||
prgb = (xrgb *) malloc(entries * sizeof(xrgb));
|
prgb = xallocarray(entries, sizeof(xrgb));
|
||||||
defs = (xColorItem *) malloc(entries * sizeof(xColorItem));
|
defs = xallocarray(entries, sizeof(xColorItem));
|
||||||
|
|
||||||
for (i = 0; i < entries; i++)
|
for (i = 0; i < entries; i++)
|
||||||
ppix[i] = i;
|
ppix[i] = i;
|
||||||
|
|
|
@ -62,7 +62,7 @@ xnestCreateColormap(ColormapPtr pCmap)
|
||||||
|
|
||||||
switch (pVisual->class) {
|
switch (pVisual->class) {
|
||||||
case StaticGray: /* read only */
|
case StaticGray: /* read only */
|
||||||
colors = (XColor *) malloc(ncolors * sizeof(XColor));
|
colors = xallocarray(ncolors, sizeof(XColor));
|
||||||
for (i = 0; i < ncolors; i++)
|
for (i = 0; i < ncolors; i++)
|
||||||
colors[i].pixel = i;
|
colors[i].pixel = i;
|
||||||
XQueryColors(xnestDisplay, xnestColormap(pCmap), colors, ncolors);
|
XQueryColors(xnestDisplay, xnestColormap(pCmap), colors, ncolors);
|
||||||
|
@ -75,7 +75,7 @@ xnestCreateColormap(ColormapPtr pCmap)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case StaticColor: /* read only */
|
case StaticColor: /* read only */
|
||||||
colors = (XColor *) malloc(ncolors * sizeof(XColor));
|
colors = xallocarray(ncolors, sizeof(XColor));
|
||||||
for (i = 0; i < ncolors; i++)
|
for (i = 0; i < ncolors; i++)
|
||||||
colors[i].pixel = i;
|
colors[i].pixel = i;
|
||||||
XQueryColors(xnestDisplay, xnestColormap(pCmap), colors, ncolors);
|
XQueryColors(xnestDisplay, xnestColormap(pCmap), colors, ncolors);
|
||||||
|
@ -88,7 +88,7 @@ xnestCreateColormap(ColormapPtr pCmap)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TrueColor: /* read only */
|
case TrueColor: /* read only */
|
||||||
colors = (XColor *) malloc(ncolors * sizeof(XColor));
|
colors = xallocarray(ncolors, sizeof(XColor));
|
||||||
red = green = blue = 0L;
|
red = green = blue = 0L;
|
||||||
redInc = lowbit(pVisual->redMask);
|
redInc = lowbit(pVisual->redMask);
|
||||||
greenInc = lowbit(pVisual->greenMask);
|
greenInc = lowbit(pVisual->greenMask);
|
||||||
|
@ -194,14 +194,12 @@ xnestSetInstalledColormapWindows(ScreenPtr pScreen)
|
||||||
xnestInstalledColormapWindows icws;
|
xnestInstalledColormapWindows icws;
|
||||||
int numWindows;
|
int numWindows;
|
||||||
|
|
||||||
icws.cmapIDs = (Colormap *) malloc(pScreen->maxInstalledCmaps *
|
icws.cmapIDs = xallocarray(pScreen->maxInstalledCmaps, sizeof(Colormap));
|
||||||
sizeof(Colormap));
|
|
||||||
icws.numCmapIDs = xnestListInstalledColormaps(pScreen, icws.cmapIDs);
|
icws.numCmapIDs = xnestListInstalledColormaps(pScreen, icws.cmapIDs);
|
||||||
icws.numWindows = 0;
|
icws.numWindows = 0;
|
||||||
WalkTree(pScreen, xnestCountInstalledColormapWindows, (void *) &icws);
|
WalkTree(pScreen, xnestCountInstalledColormapWindows, (void *) &icws);
|
||||||
if (icws.numWindows) {
|
if (icws.numWindows) {
|
||||||
icws.windows =
|
icws.windows = xallocarray(icws.numWindows + 1, sizeof(Window));
|
||||||
(Window *) malloc((icws.numWindows + 1) * sizeof(Window));
|
|
||||||
icws.index = 0;
|
icws.index = 0;
|
||||||
WalkTree(pScreen, xnestGetInstalledColormapWindows, (void *) &icws);
|
WalkTree(pScreen, xnestGetInstalledColormapWindows, (void *) &icws);
|
||||||
icws.windows[icws.numWindows] = xnestDefaultWindows[pScreen->myNum];
|
icws.windows[icws.numWindows] = xnestDefaultWindows[pScreen->myNum];
|
||||||
|
@ -220,8 +218,7 @@ xnestSetInstalledColormapWindows(ScreenPtr pScreen)
|
||||||
#ifdef _XSERVER64
|
#ifdef _XSERVER64
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
Window64 *windows =
|
Window64 *windows = xallocarray(numWindows, sizeof(Window64));
|
||||||
(Window64 *) malloc(numWindows * sizeof(Window64));
|
|
||||||
|
|
||||||
for (i = 0; i < numWindows; ++i)
|
for (i = 0; i < numWindows; ++i)
|
||||||
windows[i] = icws.windows[i];
|
windows[i] = icws.windows[i];
|
||||||
|
@ -393,7 +390,7 @@ xnestStoreColors(ColormapPtr pCmap, int nColors, xColorItem * pColors)
|
||||||
#ifdef _XSERVER64
|
#ifdef _XSERVER64
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
XColor *pColors64 = (XColor *) malloc(nColors * sizeof(XColor));
|
XColor *pColors64 = xallocarray(nColors, sizeof(XColor));
|
||||||
|
|
||||||
for (i = 0; i < nColors; ++i) {
|
for (i = 0; i < nColors; ++i) {
|
||||||
pColors64[i].pixel = pColors[i].pixel;
|
pColors64[i].pixel = pColors[i].pixel;
|
||||||
|
|
|
@ -121,8 +121,8 @@ xnestOpenDisplay(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
xnestNumDefaultColormaps = xnestNumVisuals;
|
xnestNumDefaultColormaps = xnestNumVisuals;
|
||||||
xnestDefaultColormaps = (Colormap *) malloc(xnestNumDefaultColormaps *
|
xnestDefaultColormaps = xallocarray(xnestNumDefaultColormaps,
|
||||||
sizeof(Colormap));
|
sizeof(Colormap));
|
||||||
for (i = 0; i < xnestNumDefaultColormaps; i++)
|
for (i = 0; i < xnestNumDefaultColormaps; i++)
|
||||||
xnestDefaultColormaps[i] = XCreateColormap(xnestDisplay,
|
xnestDefaultColormaps[i] = XCreateColormap(xnestDisplay,
|
||||||
DefaultRootWindow
|
DefaultRootWindow
|
||||||
|
|
|
@ -190,7 +190,7 @@ xnestDestroyGC(GCPtr pGC)
|
||||||
void
|
void
|
||||||
xnestChangeClip(GCPtr pGC, int type, void *pValue, int nRects)
|
xnestChangeClip(GCPtr pGC, int type, void *pValue, int nRects)
|
||||||
{
|
{
|
||||||
int i, size;
|
int i;
|
||||||
BoxPtr pBox;
|
BoxPtr pBox;
|
||||||
XRectangle *pRects;
|
XRectangle *pRects;
|
||||||
|
|
||||||
|
@ -204,8 +204,7 @@ xnestChangeClip(GCPtr pGC, int type, void *pValue, int nRects)
|
||||||
|
|
||||||
case CT_REGION:
|
case CT_REGION:
|
||||||
nRects = RegionNumRects((RegionPtr) pValue);
|
nRects = RegionNumRects((RegionPtr) pValue);
|
||||||
size = nRects * sizeof(*pRects);
|
pRects = xallocarray(nRects, sizeof(*pRects));
|
||||||
pRects = (XRectangle *) malloc(size);
|
|
||||||
pBox = RegionRects((RegionPtr) pValue);
|
pBox = RegionRects((RegionPtr) pValue);
|
||||||
for (i = nRects; i-- > 0;) {
|
for (i = nRects; i-- > 0;) {
|
||||||
pRects[i].x = pBox[i].x1;
|
pRects[i].x = pBox[i].x1;
|
||||||
|
|
|
@ -134,7 +134,7 @@ xnestKeyboardProc(DeviceIntPtr pDev, int onoff)
|
||||||
max_keycode - min_keycode + 1,
|
max_keycode - min_keycode + 1,
|
||||||
&mapWidth);
|
&mapWidth);
|
||||||
len = (max_keycode - min_keycode + 1) * mapWidth;
|
len = (max_keycode - min_keycode + 1) * mapWidth;
|
||||||
keymap = (KeySym *) malloc(len * sizeof(KeySym));
|
keymap = xallocarray(len, sizeof(KeySym));
|
||||||
for (i = 0; i < len; ++i)
|
for (i = 0; i < len; ++i)
|
||||||
keymap[i] = keymap64[i];
|
keymap[i] = keymap64[i];
|
||||||
XFree(keymap64);
|
XFree(keymap64);
|
||||||
|
|
|
@ -158,7 +158,7 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[])
|
||||||
if (!dixRegisterPrivateKey(&xnestCursorScreenKeyRec, PRIVATE_SCREEN, 0))
|
if (!dixRegisterPrivateKey(&xnestCursorScreenKeyRec, PRIVATE_SCREEN, 0))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
visuals = (VisualPtr) malloc(xnestNumVisuals * sizeof(VisualRec));
|
visuals = xallocarray(xnestNumVisuals, sizeof(VisualRec));
|
||||||
numVisuals = 0;
|
numVisuals = 0;
|
||||||
|
|
||||||
depths = (DepthPtr) malloc(MAXDEPTH * sizeof(DepthRec));
|
depths = (DepthPtr) malloc(MAXDEPTH * sizeof(DepthRec));
|
||||||
|
@ -224,7 +224,7 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[])
|
||||||
|
|
||||||
numVisuals++;
|
numVisuals++;
|
||||||
}
|
}
|
||||||
visuals = (VisualPtr) realloc(visuals, numVisuals * sizeof(VisualRec));
|
visuals = reallocarray(visuals, numVisuals, sizeof(VisualRec));
|
||||||
|
|
||||||
defaultVisual = visuals[xnestDefaultVisualIndex].vid;
|
defaultVisual = visuals[xnestDefaultVisualIndex].vid;
|
||||||
rootDepth = visuals[xnestDefaultVisualIndex].nplanes;
|
rootDepth = visuals[xnestDefaultVisualIndex].nplanes;
|
||||||
|
|
Loading…
Reference in New Issue