[PATCH xserver 5/8] xf86cmap: Compute colors as needed
Adam Jackson
ajax at redhat.com
Wed Jan 31 15:54:01 UTC 2018
... instead of saving them in the colormap private.
Signed-off-by: Adam Jackson <ajax at redhat.com>
---
hw/xfree86/common/xf86cmap.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/hw/xfree86/common/xf86cmap.c b/hw/xfree86/common/xf86cmap.c
index a01d02cb3..0f4926c18 100644
--- a/hw/xfree86/common/xf86cmap.c
+++ b/hw/xfree86/common/xf86cmap.c
@@ -95,7 +95,7 @@ typedef struct {
} CMapScreenRec, *CMapScreenPtr;
typedef struct {
- LOCO *colors;
+ LOCO *unused;
} CMapColormapRec, *CMapColormapPtr;
static DevPrivateKeyRec CMapScreenKeyRec;
@@ -281,20 +281,13 @@ CMapAllocateColormapPrivate(ColormapPtr pmap)
CMapScreenPtr pScreenPriv = getCMapScreenPtr(pmap->pScreen);
CMapColormapPtr pColPriv;
CMapLinkPtr pLink;
- LOCO *colors;
-
- if (!(colors = xallocarray(CMapNumColors(pmap, pScreenPriv), sizeof(LOCO))))
- return FALSE;
if (!(pColPriv = malloc(sizeof(CMapColormapRec)))) {
- free(colors);
return FALSE;
}
dixSetPrivate(&pmap->devPrivates, CMapColormapKey, pColPriv);
- pColPriv->colors = colors;
-
/* add map to list */
pLink = malloc(sizeof(CMapLink));
if (pLink) {
@@ -332,7 +325,6 @@ CMapDestroyColormap(ColormapPtr cmap)
CMapLinkPtr prevLink = NULL, pLink = pScreenPriv->maps;
if (pColPriv) {
- free(pColPriv->colors);
free(pColPriv);
}
@@ -535,7 +527,6 @@ static void
CMapRefreshColors(ColormapPtr pmap, int defs, int *indices)
{
CMapScreenPtr pScreenPriv = getCMapScreenPtr(pmap->pScreen);
- CMapColormapPtr pColPriv = getCMapColormapPtr(pmap);
VisualPtr pVisual = pmap->pVisual;
ScrnInfoPtr pScrn = xf86ScreenToScrn(pmap->pScreen);
int numColors, i;
@@ -547,7 +538,8 @@ CMapRefreshColors(ColormapPtr pmap, int defs, int *indices)
shift = 16 - pScreenPriv->sigRGBbits;
maxValue = (1 << pScreenPriv->sigRGBbits) - 1;
gamma = pScreenPriv->gamma;
- colors = pColPriv->colors;
+ if (!(colors = xallocarray(CMapNumColors(pmap, pScreenPriv), sizeof(LOCO))))
+ return;
reds = pVisual->redMask >> pVisual->offsetRed;
greens = pVisual->greenMask >> pVisual->offsetGreen;
@@ -639,6 +631,8 @@ CMapRefreshColors(ColormapPtr pmap, int defs, int *indices)
if (LOAD_PALETTE(pmap))
(*pScrn->LoadPalette) (pScrn, defs, indices, colors, pmap->pVisual);
+
+ free(colors);
}
static void
--
2.14.3
More information about the xorg-devel
mailing list