[PATCH 1/2] xnest: Replace use of Colormap->devPriv with standard devPrivates.

Jamey Sharp jamey at minilop.net
Tue Jul 13 15:37:07 PDT 2010


Signed-off-by: Jamey Sharp <jamey at minilop.net>
---
 hw/xnest/Color.c  |    5 ++---
 hw/xnest/Color.h  |    3 ++-
 hw/xnest/Screen.c |    2 ++
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/hw/xnest/Color.c b/hw/xnest/Color.c
index 883b77c..0aae8e9 100644
--- a/hw/xnest/Color.c
+++ b/hw/xnest/Color.c
@@ -34,6 +34,8 @@ is" without express or implied warranty.
 #include "XNWindow.h"
 #include "Args.h"
 
+DevPrivateKeyRec xnestColormapPrivateKeyRec;
+
 static DevPrivateKeyRec cmapScrPrivateKeyRec;
 #define cmapScrPrivateKey (&cmapScrPrivateKeyRec)
 
@@ -52,8 +54,6 @@ xnestCreateColormap(ColormapPtr pCmap)
   pVisual = pCmap->pVisual;
   ncolors = pVisual->ColormapEntries;
 
-  pCmap->devPriv = (pointer)malloc(sizeof(xnestPrivColormap));
-  
   xnestColormapPriv(pCmap)->colormap = 
     XCreateColormap(xnestDisplay,
 		    xnestDefaultWindows[pCmap->pScreen->myNum],
@@ -130,7 +130,6 @@ void
 xnestDestroyColormap(ColormapPtr pCmap)
 {
   XFreeColormap(xnestDisplay, xnestColormap(pCmap));
-  free(pCmap->devPriv);
 }
 
 #define SEARCH_PREDICATE \
diff --git a/hw/xnest/Color.h b/hw/xnest/Color.h
index f00bde4..d39c638 100644
--- a/hw/xnest/Color.h
+++ b/hw/xnest/Color.h
@@ -32,8 +32,9 @@ typedef struct {
   int index;
 } xnestInstalledColormapWindows;
 
+extern DevPrivateKeyRec xnestColormapPrivateKeyRec;
 #define xnestColormapPriv(pCmap) \
-  ((xnestPrivColormap *)((pCmap)->devPriv))
+  ((xnestPrivColormap *) dixLookupPrivate(&(pCmap)->devPrivates, &xnestColormapPrivateKeyRec))
 
 #define xnestColormap(pCmap) (xnestColormapPriv(pCmap)->colormap)
 
diff --git a/hw/xnest/Screen.c b/hw/xnest/Screen.c
index 957fe4c..0a6cab6 100644
--- a/hw/xnest/Screen.c
+++ b/hw/xnest/Screen.c
@@ -151,6 +151,8 @@ xnestOpenScreen(int index, ScreenPtr pScreen, int argc, char *argv[])
     return FALSE;
   if (!dixRegisterPrivateKey(&xnestPixmapPrivateKeyRec, PRIVATE_PIXMAP, sizeof (xnestPrivPixmap)))
       return FALSE;
+  if (!dixRegisterPrivateKey(&xnestColormapPrivateKeyRec, PRIVATE_COLORMAP, sizeof (xnestPrivColormap)))
+      return FALSE;
   if (!dixRegisterPrivateKey(&xnestCursorScreenKeyRec, PRIVATE_SCREEN, 0))
       return FALSE;
 
-- 
1.7.0



More information about the xorg-devel mailing list