summaryrefslogtreecommitdiff
path: root/dix/colormap.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2010-04-26 17:22:21 -0700
committerKeith Packard <keithp@keithp.com>2010-06-05 19:23:03 -0700
commitfaeebead7bfcc78535757ca7acc1faf7554c03b7 (patch)
tree1a8f13a3b1ae968011efb9679bc3ed79a29020be /dix/colormap.c
parentc865a24401f06bcf1347d8b41f736a066ab25693 (diff)
Change the devPrivates API to require dixRegisterPrivateKey
This patch only changes the API, not the implementation of the devPrivates infrastructure. This will permit a new devPrivates implementation to be layed into the server without requiring simultaneous changes in every devPrivates user. Signed-off-by: Keith Packard <keithp@keithp.com> Tested-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Diffstat (limited to 'dix/colormap.c')
-rw-r--r--dix/colormap.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/dix/colormap.c b/dix/colormap.c
index 12197acde..eb6c491c1 100644
--- a/dix/colormap.c
+++ b/dix/colormap.c
@@ -273,9 +273,20 @@ CreateColormap (Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
if ((class | DynamicClass) == DirectColor)
sizebytes *= 3;
sizebytes += sizeof(ColormapRec);
- pmap = malloc(sizebytes);
- if (!pmap)
- return (BadAlloc);
+ if (mid == pScreen->defColormap) {
+ pmap = malloc(sizebytes);
+ if (!pmap)
+ return (BadAlloc);
+ if (!dixAllocatePrivates(&pmap->devPrivates, PRIVATE_COLORMAP)) {
+ free (pmap);
+ return (BadAlloc);
+ }
+ } else {
+ pmap = _dixAllocateObjectWithPrivates(sizebytes, sizebytes,
+ offsetof(ColormapRec, devPrivates), PRIVATE_COLORMAP);
+ if (!pmap)
+ return (BadAlloc);
+ }
#if defined(_XSERVER64)
pmap->pad0 = 0;
pmap->pad1 = 0;
@@ -385,7 +396,6 @@ CreateColormap (Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
pmap->numPixelsBlue[client] = size;
}
}
- pmap->devPrivates = NULL;
pmap->flags |= BeingCreated;
if (!AddResource(mid, RT_COLORMAP, (pointer)pmap))
@@ -467,8 +477,11 @@ FreeColormap (pointer value, XID mid)
}
}
- dixFreePrivates(pmap->devPrivates);
- free(pmap);
+ if (pmap->flags & IsDefault) {
+ dixFreePrivates(pmap->devPrivates, PRIVATE_COLORMAP);
+ free(pmap);
+ } else
+ dixFreeObjectWithPrivates(pmap, PRIVATE_COLORMAP);
return(Success);
}