aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xnest/Color.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/hw/xnest/Color.c')
-rw-r--r--xorg-server/hw/xnest/Color.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/xorg-server/hw/xnest/Color.c b/xorg-server/hw/xnest/Color.c
index 8d9d35621..3a9e42203 100644
--- a/xorg-server/hw/xnest/Color.c
+++ b/xorg-server/hw/xnest/Color.c
@@ -62,7 +62,7 @@ xnestCreateColormap(ColormapPtr pCmap)
switch (pVisual->class) {
case StaticGray: /* read only */
- colors = (XColor *) malloc(ncolors * sizeof(XColor));
+ colors = xallocarray(ncolors, sizeof(XColor));
for (i = 0; i < ncolors; i++)
colors[i].pixel = i;
XQueryColors(xnestDisplay, xnestColormap(pCmap), colors, ncolors);
@@ -75,7 +75,7 @@ xnestCreateColormap(ColormapPtr pCmap)
break;
case StaticColor: /* read only */
- colors = (XColor *) malloc(ncolors * sizeof(XColor));
+ colors = xallocarray(ncolors, sizeof(XColor));
for (i = 0; i < ncolors; i++)
colors[i].pixel = i;
XQueryColors(xnestDisplay, xnestColormap(pCmap), colors, ncolors);
@@ -88,7 +88,7 @@ xnestCreateColormap(ColormapPtr pCmap)
break;
case TrueColor: /* read only */
- colors = (XColor *) malloc(ncolors * sizeof(XColor));
+ colors = xallocarray(ncolors, sizeof(XColor));
red = green = blue = 0L;
redInc = lowbit(pVisual->redMask);
greenInc = lowbit(pVisual->greenMask);
@@ -194,14 +194,12 @@ xnestSetInstalledColormapWindows(ScreenPtr pScreen)
xnestInstalledColormapWindows icws;
int numWindows;
- icws.cmapIDs = (Colormap *) malloc(pScreen->maxInstalledCmaps *
- sizeof(Colormap));
+ icws.cmapIDs = xallocarray(pScreen->maxInstalledCmaps, sizeof(Colormap));
icws.numCmapIDs = xnestListInstalledColormaps(pScreen, icws.cmapIDs);
icws.numWindows = 0;
WalkTree(pScreen, xnestCountInstalledColormapWindows, (void *) &icws);
if (icws.numWindows) {
- icws.windows =
- (Window *) malloc((icws.numWindows + 1) * sizeof(Window));
+ icws.windows = xallocarray(icws.numWindows + 1, sizeof(Window));
icws.index = 0;
WalkTree(pScreen, xnestGetInstalledColormapWindows, (void *) &icws);
icws.windows[icws.numWindows] = xnestDefaultWindows[pScreen->myNum];
@@ -220,8 +218,7 @@ xnestSetInstalledColormapWindows(ScreenPtr pScreen)
#ifdef _XSERVER64
{
int i;
- Window64 *windows =
- (Window64 *) malloc(numWindows * sizeof(Window64));
+ Window64 *windows = xallocarray(numWindows, sizeof(Window64));
for (i = 0; i < numWindows; ++i)
windows[i] = icws.windows[i];
@@ -393,7 +390,7 @@ xnestStoreColors(ColormapPtr pCmap, int nColors, xColorItem * pColors)
#ifdef _XSERVER64
{
int i;
- XColor *pColors64 = (XColor *) malloc(nColors * sizeof(XColor));
+ XColor *pColors64 = xallocarray(nColors, sizeof(XColor));
for (i = 0; i < nColors; ++i) {
pColors64[i].pixel = pColors[i].pixel;