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>
This commit is contained in:
Keith Packard 2010-04-26 17:22:21 -07:00
parent c865a24401
commit faeebead7b
139 changed files with 1108 additions and 714 deletions

View File

@ -36,12 +36,10 @@
#define rClient(obj) (clients[CLIENT_ID((obj)->resource)])
static int GEClientPrivateKeyIndex;
DevPrivateKey GEClientPrivateKey = &GEClientPrivateKeyIndex;
DevPrivateKeyRec GEClientPrivateKeyRec;
int RT_GECLIENT = 0;
GEExtension GEExtensions[MAXEXTENSIONS];
/* Major available requests */
@ -209,7 +207,7 @@ GEExtensionInit(void)
{
ExtensionEntry *extEntry;
if (!dixRequestPrivate(GEClientPrivateKey, sizeof(GEClientInfoRec)))
if (!dixRegisterPrivateKey(&GEClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(GEClientInfoRec)))
FatalError("GEExtensionInit: GE private request failed.\n");
if(!AddCallback(&ClientStateCallback, GEClientCallback, 0))

View File

@ -37,7 +37,8 @@
#include "extnsionst.h"
#include <X11/extensions/geproto.h>
extern _X_EXPORT DevPrivateKey GEClientPrivateKey;
extern _X_EXPORT DevPrivateKeyRec GEClientPrivateKeyRec;
#define GEClientPrivateKey (&GEClientPrivateKeyRec)
typedef struct _GEClientInfo {
CARD32 major_version;

View File

@ -103,10 +103,10 @@ static void PanoramiXResetProc(ExtensionEntry*);
int (* SavedProcVector[256]) (ClientPtr client) = { NULL, };
static int PanoramiXGCKeyIndex;
static DevPrivateKey PanoramiXGCKey = &PanoramiXGCKeyIndex;
static int PanoramiXScreenKeyIndex;
static DevPrivateKey PanoramiXScreenKey = &PanoramiXScreenKeyIndex;
static DevPrivateKeyRec PanoramiXGCKeyRec;
#define PanoramiXGCKey (&PanoramiXGCKeyRec)
static DevPrivateKeyRec PanoramiXScreenKeyRec;
#define PanoramiXScreenKey (&PanoramiXScreenKeyRec)
typedef struct {
DDXPointRec clipOrg;
@ -443,6 +443,16 @@ void PanoramiXExtensionInit(int argc, char *argv[])
if (noPanoramiXExtension)
return;
if (!dixRegisterPrivateKey(&PanoramiXScreenKeyRec, PRIVATE_SCREEN, 0)) {
noPanoramiXExtension = TRUE;
return;
}
if (!dixRegisterPrivateKey(&PanoramiXGCKeyRec, PRIVATE_GC, sizeof(PanoramiXGCRec))) {
noPanoramiXExtension = TRUE;
return;
}
PanoramiXNumScreens = screenInfo.numScreens;
if (PanoramiXNumScreens == 1) { /* Only 1 screen */
noPanoramiXExtension = TRUE;
@ -462,11 +472,6 @@ void PanoramiXExtensionInit(int argc, char *argv[])
* run in non-PanoramiXeen mode.
*/
if (!dixRequestPrivate(PanoramiXGCKey, sizeof(PanoramiXGCRec))) {
noPanoramiXExtension = TRUE;
return;
}
for (i = 0; i < PanoramiXNumScreens; i++) {
pScreen = screenInfo.screens[i];
pScreenPriv = malloc(sizeof(PanoramiXScreenRec));

View File

@ -226,8 +226,8 @@ MakeScreenPrivate (
ScreenPtr /* pScreen */
);
static int ScreenPrivateKeyIndex;
static DevPrivateKey ScreenPrivateKey = &ScreenPrivateKeyIndex;
static DevPrivateKeyRec ScreenPrivateKeyRec;
#define ScreenPrivateKey (&ScreenPrivateKeyRec)
#define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr) \
dixLookupPrivate(&(s)->devPrivates, ScreenPrivateKey))
@ -252,6 +252,9 @@ ScreenSaverExtensionInit(INITARGS)
int i;
ScreenPtr pScreen;
if (!dixRegisterPrivateKey(&ScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
return;
AttrType = CreateNewResourceType(ScreenSaverFreeAttr, "SaverAttr");
SaverEventType = CreateNewResourceType(ScreenSaverFreeEvents,
"SaverEvent");

View File

@ -51,8 +51,8 @@ static RESTYPE RTEventClient;
static CallbackListPtr SecurityValidateGroupCallback = NULL;
/* Private state record */
static int stateKeyIndex;
static DevPrivateKey stateKey = &stateKeyIndex;
static DevPrivateKeyRec stateKeyRec;
#define stateKey (&stateKeyRec)
/* This is what we store as client security state */
typedef struct {
@ -1108,7 +1108,7 @@ SecurityExtensionInit(INITARGS)
RTEventClient |= RC_NEVERRETAIN;
/* Allocate the private storage */
if (!dixRequestPrivate(stateKey, sizeof(SecurityStateRec)))
if (!dixRegisterPrivateKey(stateKey, PRIVATE_CLIENT, sizeof(SecurityStateRec)))
FatalError("SecurityExtensionSetup: Can't allocate client private.\n");
/* Register callbacks */

View File

@ -141,10 +141,10 @@ int BadShmSegCode;
RESTYPE ShmSegType;
static ShmDescPtr Shmsegs;
static Bool sharedPixmaps;
static int shmScrPrivateKeyIndex;
static DevPrivateKey shmScrPrivateKey = &shmScrPrivateKeyIndex;
static int shmPixmapPrivateIndex;
static DevPrivateKey shmPixmapPrivate = &shmPixmapPrivateIndex;
static DevPrivateKeyRec shmScrPrivateKeyRec;
#define shmScrPrivateKey (&shmScrPrivateKeyRec)
static DevPrivateKeyRec shmPixmapPrivateKeyRec;
#define shmPixmapPrivateKey (&shmPixmapPrivateKeyRec)
static ShmFuncs miFuncs = {NULL, NULL};
static ShmFuncs fbFuncs = {fbShmCreatePixmap, NULL};
@ -244,6 +244,16 @@ ShmInitScreenPriv(ScreenPtr pScreen)
return screen_priv;
}
static Bool
ShmRegisterPrivates(void)
{
if (!dixRegisterPrivateKey(&shmScrPrivateKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if (!dixRegisterPrivateKey(&shmPixmapPrivateKeyRec, PRIVATE_PIXMAP, 0))
return FALSE;
return TRUE;
}
void
ShmExtensionInit(INITARGS)
{
@ -258,6 +268,9 @@ ShmExtensionInit(INITARGS)
}
#endif
if (!ShmRegisterPrivates())
return;
sharedPixmaps = xFalse;
{
sharedPixmaps = xTrue;
@ -303,6 +316,8 @@ ShmResetProc(ExtensionEntry *extEntry)
void
ShmRegisterFuncs(ScreenPtr pScreen, ShmFuncsPtr funcs)
{
if (!ShmRegisterPrivates())
return;
ShmInitScreenPriv(pScreen)->shmFuncs = funcs;
}
@ -316,7 +331,7 @@ ShmDestroyPixmap (PixmapPtr pPixmap)
{
ShmDescPtr shmdesc;
shmdesc = (ShmDescPtr)dixLookupPrivate(&pPixmap->devPrivates,
shmPixmapPrivate);
shmPixmapPrivateKey);
if (shmdesc)
ShmDetachSegment ((pointer) shmdesc, pPixmap->drawable.id);
}
@ -817,7 +832,7 @@ CreatePmap:
shmdesc->addr + stuff->offset);
if (pMap) {
dixSetPrivate(&pMap->devPrivates, shmPixmapPrivate, shmdesc);
dixSetPrivate(&pMap->devPrivates, shmPixmapPrivateKey, shmdesc);
shmdesc->refcnt++;
pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
pMap->drawable.id = newPix->info[j].id;
@ -1156,7 +1171,7 @@ CreatePmap:
pDraw->pScreen->DestroyPixmap(pMap);
return rc;
}
dixSetPrivate(&pMap->devPrivates, shmPixmapPrivate, shmdesc);
dixSetPrivate(&pMap->devPrivates, shmPixmapPrivateKey, shmdesc);
shmdesc->refcnt++;
pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
pMap->drawable.id = stuff->pid;

View File

@ -59,12 +59,9 @@ typedef struct {
} SELinuxAuditRec;
/* private state keys */
static int subjectKeyIndex;
DevPrivateKey subjectKey = &subjectKeyIndex;
static int objectKeyIndex;
DevPrivateKey objectKey = &objectKeyIndex;
static int dataKeyIndex;
DevPrivateKey dataKey = &dataKeyIndex;
DevPrivateKeyRec subjectKeyRec;
DevPrivateKeyRec objectKeyRec;
DevPrivateKeyRec dataKeyRec;
/* audit file descriptor */
static int audit_fd;
@ -896,9 +893,9 @@ SELinuxFlaskInit(void)
FatalError("SELinux: Failed to open the system audit log\n");
/* Allocate private storage */
if (!dixRequestPrivate(subjectKey, sizeof(SELinuxSubjectRec)) ||
!dixRequestPrivate(objectKey, sizeof(SELinuxObjectRec)) ||
!dixRequestPrivate(dataKey, sizeof(SELinuxObjectRec)))
if (!dixRegisterPrivateKey(subjectKey, PRIVATE_XSELINUX, sizeof(SELinuxSubjectRec)) ||
!dixRegisterPrivateKey(objectKey, PRIVATE_XSELINUX, sizeof(SELinuxObjectRec)) ||
!dixRegisterPrivateKey(dataKey, PRIVATE_XSELINUX, sizeof(SELinuxObjectRec)))
FatalError("SELinux: Failed to allocate private storage.\n");
/* Create atoms for doing window labeling */

View File

@ -62,9 +62,12 @@ typedef struct {
* Globals
*/
extern DevPrivateKey subjectKey;
extern DevPrivateKey objectKey;
extern DevPrivateKey dataKey;
extern DevPrivateKeyRec subjectKeyRec;
#define subjectKey (&subjectKeyRec)
extern DevPrivateKeyRec objectKeyRec;
#define objectKey (&objectKeyRec)
extern DevPrivateKeyRec dataKeyRec;
#define dataKey (&dataKeyRec)
/*
* Label functions

View File

@ -63,8 +63,8 @@ extern int DeviceValuator;
static EventListPtr xtest_evlist;
/* Used to store if a device is an XTest Virtual device */
static int XTestDevicePrivateKeyIndex;
DevPrivateKey XTestDevicePrivateKey = &XTestDevicePrivateKeyIndex;
static DevPrivateKeyRec XTestDevicePrivateKeyRec;
#define XTestDevicePrivateKey (&XTestDevicePrivateKeyRec)
/**
* xtestpointer
@ -102,6 +102,9 @@ static DISPATCH_PROC(SProcXTestGrabControl);
void
XTestExtensionInit(INITARGS)
{
if (!dixRegisterPrivateKey(&XTestDevicePrivateKeyRec, PRIVATE_DEVICE, 0))
return;
AddExtension(XTestExtensionName, 0, 0,
ProcXTestDispatch, SProcXTestDispatch,
NULL, StandardMinorOpcode);

View File

@ -105,8 +105,8 @@ SOFTWARE.
#endif
#include "xvdisp.h"
static int XvScreenKeyIndex;
static DevPrivateKey XvScreenKey = &XvScreenKeyIndex;
static DevPrivateKeyRec XvScreenKeyRec;
#define XvScreenKey (&XvScreenKeyRec)
unsigned long XvExtensionGeneration = 0;
unsigned long XvScreenGeneration = 0;
unsigned long XvResourceGeneration = 0;
@ -156,6 +156,9 @@ XvExtensionInit(void)
{
ExtensionEntry *extEntry;
if (!dixRegisterPrivateKey(&XvScreenKeyRec, PRIVATE_SCREEN, 0))
return;
/* LOOK TO SEE IF ANY SCREENS WERE INITIALIZED; IF NOT THEN
INIT GLOBAL VARIABLES SO THE EXTENSION CAN FUNCTION */
if (XvScreenGeneration != serverGeneration)
@ -269,6 +272,9 @@ XvScreenInit(ScreenPtr pScreen)
XvScreenGeneration = serverGeneration;
}
if (!dixRegisterPrivateKey(&XvScreenKeyRec, PRIVATE_SCREEN, 0))
return BadAlloc;
if (dixLookupPrivate(&pScreen->devPrivates, XvScreenKey))
{
ErrorF("XvScreenInit: screen devPrivates ptr non-NULL before init\n");
@ -284,7 +290,6 @@ XvScreenInit(ScreenPtr pScreen)
}
dixSetPrivate(&pScreen->devPrivates, XvScreenKey, pxvs);
pxvs->DestroyPixmap = pScreen->DestroyPixmap;
pxvs->DestroyWindow = pScreen->DestroyWindow;

View File

@ -33,8 +33,9 @@
#define DR_CLIENT_DRIVER_NAME_SIZE 48
#define DR_BUSID_SIZE 48
static int XvMCScreenKeyIndex;
static DevPrivateKey XvMCScreenKey;
static DevPrivateKeyRec XvMCScreenKeyRec;
#define XvMCScreenKey (&XvMCScreenKeyRec)
static Bool XvMCInUse;
unsigned long XvMCGeneration = 0;
@ -138,7 +139,7 @@ ProcXvMCListSurfaceTypes(ClientPtr client)
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
if(XvMCScreenKey) { /* any adaptors at all */
if(XvMCInUse) { /* any adaptors at all */
ScreenPtr pScreen = pPort->pAdaptor->pScreen;
if((pScreenPriv = XVMC_GET_PRIVATE(pScreen))) { /* any this screen */
for(i = 0; i < pScreenPriv->num_adaptors; i++) {
@ -193,7 +194,7 @@ ProcXvMCCreateContext(ClientPtr client)
pScreen = pPort->pAdaptor->pScreen;
if(XvMCScreenKey == NULL) /* no XvMC adaptors */
if(!XvMCInUse) /* no XvMC adaptors */
return BadMatch;
if(!(pScreenPriv = XVMC_GET_PRIVATE(pScreen))) /* none this screen */
@ -716,7 +717,8 @@ XvMCScreenInit(ScreenPtr pScreen, int num, XvMCAdaptorPtr pAdapt)
{
XvMCScreenPtr pScreenPriv;
XvMCScreenKey = &XvMCScreenKeyIndex;
if (!dixRegisterPrivateKey(&XvMCScreenKeyRec, PRIVATE_SCREEN, 0))
return BadAlloc;
if(!(pScreenPriv = malloc(sizeof(XvMCScreenRec))))
return BadAlloc;
@ -734,6 +736,8 @@ XvMCScreenInit(ScreenPtr pScreen, int num, XvMCAdaptorPtr pAdapt)
pScreenPriv->minor = 0;
pScreenPriv->patchLevel = 0;
XvMCInUse = TRUE;
return Success;
}

View File

@ -78,5 +78,7 @@ extern int DevicePropertyNotify;
extern int RT_INPUTCLIENT;
extern DevPrivateKey XIClientPrivateKey;
extern DevPrivateKeyRec XIClientPrivateKeyRec;
#define XIClientPrivateKey (&XIClientPrivateKeyRec)
#endif /* EXGLOBALS_H */

View File

@ -377,9 +377,7 @@ Mask PropagateMask[MAXDEVICES];
*
*/
static int XIClientPrivateKeyIndex;
DevPrivateKey XIClientPrivateKey = &XIClientPrivateKeyIndex;
DevPrivateKeyRec XIClientPrivateKeyRec;
/*****************************************************************
*
@ -1256,7 +1254,7 @@ XInputExtensionInit(void)
SERVER_XI_MINOR_VERSION,
};
if (!dixRequestPrivate(XIClientPrivateKey, sizeof(XIClientRec)))
if (!dixRegisterPrivateKey(&XIClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(XIClientRec)))
FatalError("Cannot request private for XI.\n");
if (!AddCallback(&ClientStateCallback, XIClientCallback, 0))

View File

@ -50,8 +50,8 @@
#include "protocol-versions.h"
static CARD8 CompositeReqCode;
static int CompositeClientPrivateKeyIndex;
static DevPrivateKey CompositeClientPrivateKey = &CompositeClientPrivateKeyIndex;
static DevPrivateKeyRec CompositeClientPrivateKeyRec;
#define CompositeClientPrivateKey (&CompositeClientPrivateKeyRec)
RESTYPE CompositeClientWindowType;
RESTYPE CompositeClientSubwindowsType;
RESTYPE CompositeClientOverlayType;
@ -558,8 +558,8 @@ CompositeExtensionInit (void)
if (!CompositeClientOverlayType)
return;
if (!dixRequestPrivate(CompositeClientPrivateKey,
sizeof(CompositeClientRec)))
if (!dixRegisterPrivateKey(&CompositeClientPrivateKeyRec, PRIVATE_CLIENT,
sizeof(CompositeClientRec)))
return;
if (!AddCallback (&ClientStateCallback, CompositeClientCallback, 0))

View File

@ -48,13 +48,9 @@
#include "compint.h"
#include "compositeext.h"
static int CompScreenPrivateKeyIndex;
DevPrivateKey CompScreenPrivateKey = &CompScreenPrivateKeyIndex;
static int CompWindowPrivateKeyIndex;
DevPrivateKey CompWindowPrivateKey = &CompWindowPrivateKeyIndex;
static int CompSubwindowsPrivateKeyIndex;
DevPrivateKey CompSubwindowsPrivateKey = &CompSubwindowsPrivateKeyIndex;
DevPrivateKeyRec CompScreenPrivateKeyRec;
DevPrivateKeyRec CompWindowPrivateKeyRec;
DevPrivateKeyRec CompSubwindowsPrivateKeyRec;
static Bool
compCloseScreen (int index, ScreenPtr pScreen)
@ -319,6 +315,13 @@ compScreenInit (ScreenPtr pScreen)
{
CompScreenPtr cs;
if (!dixRegisterPrivateKey(&CompScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if (!dixRegisterPrivateKey(&CompWindowPrivateKeyRec, PRIVATE_WINDOW, 0))
return FALSE;
if (!dixRegisterPrivateKey(&CompSubwindowsPrivateKeyRec, PRIVATE_WINDOW, 0))
return FALSE;
if (GetCompScreen (pScreen))
return TRUE;
cs = (CompScreenPtr) malloc(sizeof (CompScreenRec));

View File

@ -157,9 +157,14 @@ typedef struct _CompScreen {
} CompScreenRec, *CompScreenPtr;
extern DevPrivateKey CompScreenPrivateKey;
extern DevPrivateKey CompWindowPrivateKey;
extern DevPrivateKey CompSubwindowsPrivateKey;
extern DevPrivateKeyRec CompScreenPrivateKeyRec;
#define CompScreenPrivateKey (&CompScreenPrivateKeyRec)
extern DevPrivateKeyRec CompWindowPrivateKeyRec;
#define CompWindowPrivateKey (&CompWindowPrivateKeyRec)
extern DevPrivateKeyRec CompSubwindowsPrivateKeyRec;
#define CompSubwindowsPrivateKey (&CompSubwindowsPrivateKeyRec)
#define GetCompScreen(s) ((CompScreenPtr) \
dixLookupPrivate(&(s)->devPrivates, CompScreenPrivateKey))

View File

@ -32,8 +32,8 @@ static int DamageEventBase;
static RESTYPE DamageExtType;
static RESTYPE DamageExtWinType;
static int DamageClientPrivateKeyIndex;
static DevPrivateKey DamageClientPrivateKey = &DamageClientPrivateKeyIndex;
static DevPrivateKeyRec DamageClientPrivateKeyRec;
#define DamageClientPrivateKey (&DamageClientPrivateKeyRec)
#define prScreen screenInfo.screens[0]
@ -502,8 +502,9 @@ DamageExtensionInit(void)
if (!DamageExtWinType)
return;
if (!dixRequestPrivate(DamageClientPrivateKey, sizeof (DamageClientRec)))
if (!dixRegisterPrivateKey(&DamageClientPrivateKeyRec, PRIVATE_CLIENT, sizeof (DamageClientRec)))
return;
if (!AddCallback (&ClientStateCallback, DamageClientCallback, 0))
return;

View File

@ -57,15 +57,13 @@
/* GLOBALS */
/* These are static globals copied to DBE's screen private for use by DDX */
static int dbeScreenPrivKeyIndex;
static DevPrivateKey dbeScreenPrivKey = &dbeScreenPrivKeyIndex;
static int dbeWindowPrivKeyIndex;
static DevPrivateKey dbeWindowPrivKey = &dbeWindowPrivKeyIndex;
/* These are globals for use by DDX */
DevPrivateKeyRec dbeScreenPrivKeyRec;
DevPrivateKeyRec dbeWindowPrivKeyRec;
/* These are static globals copied to DBE's screen private for use by DDX */
static RESTYPE dbeDrawableResType;
static RESTYPE dbeWindowPrivResType;
/* These are globals for use by DDX */
RESTYPE dbeDrawableResType;
RESTYPE dbeWindowPrivResType;
/* Used to generate DBE's BadBuffer error. */
static int dbeErrorBase;
@ -254,7 +252,7 @@ ProcDbeAllocateBackBufferName(ClientPtr client)
* Allocate a window priv.
*/
pDbeWindowPriv = calloc(1, sizeof(DbeWindowPrivRec));
pDbeWindowPriv = dixAllocateObjectWithPrivates(DbeWindowPrivRec, PRIVATE_DBE_WINDOW);
if (!pDbeWindowPriv)
return(BadAlloc);
@ -1410,8 +1408,7 @@ DbeWindowPrivDelete(pointer pDbeWinPriv, XID id)
NULL);
/* We are done with the window priv. */
dixFreePrivates(pDbeWindowPriv->devPrivates);
free(pDbeWindowPriv);
dixFreeObjectWithPrivates(pDbeWindowPriv, PRIVATE_DBE_WINDOW);
}
return(Success);
@ -1576,6 +1573,12 @@ DbeExtensionInit(void)
if (!dbeWindowPrivResType)
return;
if (!dixRegisterPrivateKey(&dbeScreenPrivKeyRec, PRIVATE_SCREEN, 0))
return;
if (!dixRegisterPrivateKey(&dbeWindowPrivKeyRec, PRIVATE_WINDOW, 0))
return;
for (i = 0; i < screenInfo.numScreens; i++)
{
/* For each screen, set up DBE screen privates and init DIX and DDX
@ -1602,14 +1605,6 @@ DbeExtensionInit(void)
dixSetPrivate(&pScreen->devPrivates, dbeScreenPrivKey, pDbeScreenPriv);
/* Copy the resource types */
pDbeScreenPriv->dbeDrawableResType = dbeDrawableResType;
pDbeScreenPriv->dbeWindowPrivResType = dbeWindowPrivResType;
/* Copy the private indices */
pDbeScreenPriv->dbeScreenPrivKey = dbeScreenPrivKey;
pDbeScreenPriv->dbeWindowPrivKey = dbeWindowPrivKey;
{
/* We don't have DDX support for DBE anymore */

View File

@ -167,14 +167,6 @@ typedef struct _DbeWindowPrivRec
typedef struct _DbeScreenPrivRec
{
/* Resources created by DIX to be used by DDX */
RESTYPE dbeDrawableResType;
RESTYPE dbeWindowPrivResType;
/* Private indices created by DIX to be used by DDX */
DevPrivateKey dbeScreenPrivKey;
DevPrivateKey dbeWindowPrivKey;
/* Wrapped functions
* It is the responsibilty of the DDX layer to wrap PositionWindow().
* DbeExtensionInit wraps DestroyWindow().

View File

@ -58,14 +58,8 @@
#include <stdio.h>
static int miDbeWindowPrivPrivKeyIndex;
static DevPrivateKey miDbeWindowPrivPrivKey = &miDbeWindowPrivPrivKeyIndex;
static RESTYPE dbeDrawableResType;
static RESTYPE dbeWindowPrivResType;
static int dbeScreenPrivKeyIndex;
static DevPrivateKey dbeScreenPrivKey = &dbeScreenPrivKeyIndex;
static int dbeWindowPrivKeyIndex;
static DevPrivateKey dbeWindowPrivKey = &dbeWindowPrivKeyIndex;
static DevPrivateKeyRec miDbeWindowPrivPrivKeyRec;
#define miDbeWindowPrivPrivKey (&miDbeWindowPrivPrivKeyRec)
/******************************************************************************
@ -787,16 +781,8 @@ miDbeResetProc(ScreenPtr pScreen)
Bool
miDbeInit(ScreenPtr pScreen, DbeScreenPrivPtr pDbeScreenPriv)
{
/* Copy resource types created by DIX */
dbeDrawableResType = pDbeScreenPriv->dbeDrawableResType;
dbeWindowPrivResType = pDbeScreenPriv->dbeWindowPrivResType;
/* Copy private indices created by DIX */
dbeScreenPrivKey = pDbeScreenPriv->dbeScreenPrivKey;
dbeWindowPrivKey = pDbeScreenPriv->dbeWindowPrivKey;
if (!dixRequestPrivate(miDbeWindowPrivPrivKey,
sizeof(MiDbeWindowPrivPrivRec)))
if (!dixRegisterPrivateKey(&miDbeWindowPrivPrivKeyRec, PRIVATE_DBE_WINDOW,
sizeof(MiDbeWindowPrivPrivRec)))
return(FALSE);
/* Wrap functions. */

View File

@ -36,6 +36,8 @@
#ifndef MIDBE_H
#define MIDBE_H
#include "privates.h"
/* EXTERNS */
extern Bool miDbeInit(
@ -43,5 +45,14 @@ extern Bool miDbeInit(
DbeScreenPrivPtr pDbeScreenPriv
);
extern DevPrivateKeyRec dbeScreenPrivKeyRec;
#define dbeScreenPrivKey (&dbeScreenPrivKeyRec)
extern DevPrivateKeyRec dbeWindowPrivKeyRec;
#define dbeWindowPrivKey (&dbeWindowPrivKeyRec)
extern RESTYPE dbeDrawableResType;
extern RESTYPE dbeWindowPrivResType;
#endif /* MIDBE_H */

View File

@ -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);
}

View File

@ -72,6 +72,8 @@ typedef struct _GlyphShare {
static GlyphSharePtr sharedGlyphs = (GlyphSharePtr)NULL;
DevPrivateKeyRec cursorScreenDevPriv[MAXSCREENS];
#ifdef XFIXES
static CARD32 cursorSerial;
#endif
@ -86,8 +88,7 @@ FreeCursorBits(CursorBitsPtr bits)
#ifdef ARGB_CURSOR
free(bits->argb);
#endif
dixFreePrivates(bits->devPrivates);
bits->devPrivates = NULL;
dixFiniPrivates(bits, PRIVATE_CURSOR_BITS);
if (bits->refcnt == 0)
{
GlyphSharePtr *prev, this;
@ -128,8 +129,8 @@ FreeCursor(pointer value, XID cid)
pscr = screenInfo.screens[nscr];
(void)( *pscr->UnrealizeCursor)(pDev, pscr, pCurs);
}
dixFreePrivates(pCurs->devPrivates);
FreeCursorBits(pCurs->bits);
dixFiniPrivates(pCurs, PRIVATE_CURSOR);
free( pCurs);
return(Success);
}
@ -217,6 +218,7 @@ RealizeCursorAllScreens(CursorPtr pCurs)
return Success;
}
/**
* does nothing about the resource table, just creates the data structure.
* does not copy the src and mask bits
@ -237,14 +239,16 @@ AllocARGBCursor(unsigned char *psrcbits, unsigned char *pmaskbits,
int rc;
*ppCurs = NULL;
pCurs = (CursorPtr)calloc(sizeof(CursorRec) + sizeof(CursorBits), 1);
pCurs = (CursorPtr)calloc(CURSOR_REC_SIZE + CURSOR_BITS_SIZE, 1);
if (!pCurs)
{
free(psrcbits);
free(pmaskbits);
return BadAlloc;
}
bits = (CursorBitsPtr)((char *)pCurs + sizeof(CursorRec));
bits = (CursorBitsPtr)((char *)pCurs + CURSOR_REC_SIZE);
dixInitPrivates(pCurs, pCurs + 1, PRIVATE_CURSOR);
dixInitPrivates(bits, bits + 1, PRIVATE_CURSOR_BITS)
bits->source = psrcbits;
bits->mask = pmaskbits;
#ifdef ARGB_CURSOR
@ -255,7 +259,6 @@ AllocARGBCursor(unsigned char *psrcbits, unsigned char *pmaskbits,
bits->xhot = cm->xhot;
bits->yhot = cm->yhot;
pCurs->refcnt = 1;
bits->devPrivates = NULL;
bits->refcnt = -1;
CheckForEmptyMask(bits);
pCurs->bits = bits;
@ -273,7 +276,6 @@ AllocARGBCursor(unsigned char *psrcbits, unsigned char *pmaskbits,
pCurs->backBlue = backBlue;
pCurs->id = cid;
pCurs->devPrivates = NULL;
/* security creation/labeling check */
rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, RT_CURSOR,
@ -289,8 +291,8 @@ AllocARGBCursor(unsigned char *psrcbits, unsigned char *pmaskbits,
return Success;
error:
dixFreePrivates(pCurs->devPrivates);
FreeCursorBits(bits);
dixFiniPrivates(pCurs, PRIVATE_CURSOR);
free(pCurs);
return rc;
@ -339,9 +341,10 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
}
if (pShare)
{
pCurs = (CursorPtr)calloc(sizeof(CursorRec), 1);
pCurs = (CursorPtr)calloc(CURSOR_REC_SIZE, 1);
if (!pCurs)
return BadAlloc;
dixInitPrivates(pCurs, pCurs + 1, PRIVATE_CURSOR);
bits = pShare->bits;
bits->refcnt++;
}
@ -382,17 +385,17 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
if (sourcefont != maskfont)
{
pCurs =
(CursorPtr)calloc(sizeof(CursorRec) + sizeof(CursorBits), 1);
(CursorPtr)calloc(CURSOR_REC_SIZE + CURSOR_BITS_SIZE, 1);
if (pCurs)
bits = (CursorBitsPtr)((char *)pCurs + sizeof(CursorRec));
bits = (CursorBitsPtr)((char *)pCurs + CURSOR_REC_SIZE);
else
bits = (CursorBitsPtr)NULL;
}
else
{
pCurs = (CursorPtr)calloc(sizeof(CursorRec), 1);
pCurs = (CursorPtr)calloc(CURSOR_REC_SIZE, 1);
if (pCurs)
bits = (CursorBitsPtr)calloc(sizeof(CursorBits), 1);
bits = (CursorBitsPtr)calloc(CURSOR_BITS_SIZE, 1);
else
bits = (CursorBitsPtr)NULL;
}
@ -403,6 +406,8 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
free(srcbits);
return BadAlloc;
}
dixInitPrivates(pCurs, pCurs + 1, PRIVATE_CURSOR);
dixInitPrivates(bits, bits + 1, PRIVATE_CURSOR_BITS);
bits->source = srcbits;
bits->mask = mskbits;
#ifdef ARGB_CURSOR
@ -412,7 +417,6 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
bits->height = cm.height;
bits->xhot = cm.xhot;
bits->yhot = cm.yhot;
bits->devPrivates = NULL;
if (sourcefont != maskfont)
bits->refcnt = -1;
else
@ -451,7 +455,6 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
pCurs->backBlue = backBlue;
pCurs->id = cid;
pCurs->devPrivates = NULL;
/* security creation/labeling check */
rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, RT_CURSOR,
@ -467,8 +470,8 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
return Success;
error:
dixFreePrivates(pCurs->devPrivates);
FreeCursorBits(bits);
dixFiniPrivates(pCurs, PRIVATE_CURSOR);
free(pCurs);
return rc;

View File

@ -255,7 +255,9 @@ AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart)
if (devid >= MAXDEVICES)
return (DeviceIntPtr)NULL;
dev = calloc(sizeof(DeviceIntRec) + sizeof(SpriteInfoRec), 1);
dev = _dixAllocateObjectWithPrivates(sizeof(DeviceIntRec) + sizeof(SpriteInfoRec),
sizeof(DeviceIntRec) + sizeof(SpriteInfoRec),
offsetof(DeviceIntRec, devPrivates), PRIVATE_DEVICE);
if (!dev)
return (DeviceIntPtr)NULL;
dev->id = devid;
@ -936,8 +938,7 @@ CloseDevice(DeviceIntPtr dev)
}
free(dev->deviceGrab.sync.event);
dixFreePrivates(dev->devPrivates);
free(dev);
dixFreeObjectWithPrivates(dev, PRIVATE_DEVICE);
}
/**

View File

@ -3498,8 +3498,7 @@ CloseDownClient(ClientPtr client)
nextFreeClientID = client->index;
clients[client->index] = NullClient;
SmartLastClient = NullClient;
dixFreePrivates(client->devPrivates);
free(client);
dixFreeObjectWithPrivates(client, PRIVATE_CLIENT);
while (!clients[currentMaxClients-1])
currentMaxClients--;
@ -3520,7 +3519,6 @@ KillAllClients(void)
void InitClient(ClientPtr client, int i, pointer ospriv)
{
memset(client, 0, sizeof(*client));
client->index = i;
client->clientAsMask = ((Mask)i) << CLIENTOFFSET;
client->closeDownMode = i ? DestroyAll : RetainPermanent;
@ -3548,13 +3546,13 @@ ClientPtr NextAvailableClient(pointer ospriv)
i = nextFreeClientID;
if (i == MAXCLIENTS)
return (ClientPtr)NULL;
clients[i] = client = malloc(sizeof(ClientRec));
clients[i] = client = dixAllocateObjectWithPrivates(ClientRec, PRIVATE_CLIENT);
if (!client)
return (ClientPtr)NULL;
InitClient(client, i, ospriv);
if (!InitClientResources(client))
{
free(client);
dixFreeObjectWithPrivates(client, PRIVATE_CLIENT);
return (ClientPtr)NULL;
}
data.reqType = 1;
@ -3562,7 +3560,7 @@ ClientPtr NextAvailableClient(pointer ospriv)
if (!InsertFakeRequest(client, (char *)&data, sz_xReq))
{
FreeClientResources(client);
free(client);
dixFreeObjectWithPrivates(client, PRIVATE_CLIENT);
return (ClientPtr)NULL;
}
if (i == currentMaxClients)
@ -3868,9 +3866,12 @@ AddScreen(
if (!pScreen)
return -1;
pScreen->devPrivates = NULL;
if (!dixAllocatePrivates(&pScreen->devPrivates, PRIVATE_SCREEN)) {
free (pScreen);
return -1;
}
pScreen->myNum = i;
pScreen->totalPixmapSize = BitmapBytePad(sizeof(PixmapRec)*8);
pScreen->totalPixmapSize = 0; /* computed in CreateScratchPixmapForScreen */
pScreen->ClipNotify = 0; /* for R4 ddx compatibility */
pScreen->CreateScreenResources = 0;
@ -3920,10 +3921,13 @@ AddScreen(
screenInfo.numScreens++;
if (!(*pfnInit)(i, pScreen, argc, argv))
{
dixFreePrivates(pScreen->devPrivates);
dixFreePrivates(pScreen->devPrivates, PRIVATE_SCREEN);
free(pScreen);
screenInfo.numScreens--;
return -1;
}
dixRegisterPrivateKey(&cursorScreenDevPriv[i], PRIVATE_CURSOR, 0);
return i;
}

View File

@ -89,15 +89,19 @@ AddExtension(char *name, int NumEvents, int NumErrors,
return((ExtensionEntry *) NULL);
}
ext = malloc(sizeof(ExtensionEntry));
ext = calloc(sizeof (ExtensionEntry), 1);
if (!ext)
return(NULL);
if (!dixAllocatePrivates(&ext->devPrivates, PRIVATE_EXTENSION)) {
free(ext);
return(NULL);
}
ext->name = malloc(strlen(name) + 1);
ext->num_aliases = 0;
ext->aliases = (char **)NULL;
ext->devPrivates = NULL;
if (!ext->name)
{
dixFreePrivates(ext->devPrivates, PRIVATE_EXTENSION);
free(ext);
return((ExtensionEntry *) NULL);
}
@ -108,6 +112,7 @@ AddExtension(char *name, int NumEvents, int NumErrors,
if (!newexts)
{
free(ext->name);
dixFreePrivates(ext->devPrivates, PRIVATE_EXTENSION);
free(ext);
return((ExtensionEntry *) NULL);
}
@ -253,7 +258,7 @@ CloseDownExtensions(void)
for (j = extensions[i]->num_aliases; --j >= 0;)
free(extensions[i]->aliases[j]);
free(extensions[i]->aliases);
dixFreePrivates(extensions[i]->devPrivates);
dixFreePrivates(extensions[i]->devPrivates, PRIVATE_EXTENSION);
free(extensions[i]);
}
free(extensions);

View File

@ -479,7 +479,7 @@ CreateGC(DrawablePtr pDrawable, BITS32 mask, XID *pval, int *pStatus,
{
GCPtr pGC;
pGC = malloc(sizeof(GC));
pGC = dixAllocateObjectWithPrivates(GC, PRIVATE_GC);
if (!pGC)
{
*pStatus = BadAlloc;
@ -492,7 +492,6 @@ CreateGC(DrawablePtr pDrawable, BITS32 mask, XID *pval, int *pStatus,
pGC->planemask = ~0;
pGC->serialNumber = GC_CHANGE_SERIAL_BIT;
pGC->funcs = 0;
pGC->devPrivates = NULL;
pGC->fgPixel = 0;
pGC->bgPixel = 1;
pGC->lineWidth = 0;
@ -785,8 +784,7 @@ FreeGC(pointer value, XID gid)
(*pGC->funcs->DestroyGC) (pGC);
if (pGC->dash != DefaultDash)
free(pGC->dash);
dixFreePrivates(pGC->devPrivates);
free(pGC);
dixFreeObjectWithPrivates(pGC, PRIVATE_GC);
return(Success);
}
@ -808,7 +806,7 @@ CreateScratchGC(ScreenPtr pScreen, unsigned depth)
{
GCPtr pGC;
pGC = malloc(sizeof(GC));
pGC = dixAllocateObjectWithPrivates(GC, PRIVATE_GC);
if (!pGC)
return (GCPtr)NULL;
@ -817,7 +815,6 @@ CreateScratchGC(ScreenPtr pScreen, unsigned depth)
pGC->alu = GXcopy; /* dst <- src */
pGC->planemask = ~0;
pGC->serialNumber = 0;
pGC->devPrivates = NULL;
pGC->fgPixel = 0;
pGC->bgPixel = 1;
pGC->lineWidth = 0;

View File

@ -123,8 +123,6 @@ CursorPtr rootCursor;
Bool party_like_its_1989 = FALSE;
Bool whiteRoot = FALSE;
int cursorScreenDevPriv[MAXSCREENS];
TimeStamp currentTime;
TimeStamp lastDeviceEventTime;

View File

@ -174,7 +174,7 @@ int main(int argc, char *argv[], char *envp[])
InitProcVectors();
for (i=1; i<MAXCLIENTS; i++)
clients[i] = NullClient;
serverClient = malloc(sizeof(ClientRec));
serverClient = calloc(sizeof(ClientRec), 1);
if (!serverClient)
FatalError("couldn't create server client");
InitClient(serverClient, 0, (pointer)NULL);
@ -184,6 +184,12 @@ int main(int argc, char *argv[], char *envp[])
clients[0] = serverClient;
currentMaxClients = 1;
/* Initialize server client devPrivates, to be reallocated as
* more client privates are registered
*/
if (!dixAllocatePrivates(&serverClient->devPrivates, PRIVATE_CLIENT))
FatalError("failed to create server client privates");
if (!InitClientResources(serverClient)) /* for root resources */
FatalError("couldn't init server resources");
@ -194,8 +200,7 @@ int main(int argc, char *argv[], char *envp[])
InitEvents();
InitSelections();
InitGlyphCaching();
if (!dixResetPrivates())
FatalError("couldn't init private data storage");
dixResetPrivates();
dixResetRegistry();
ResetFontPrivateIndex();
InitCallbackManager();
@ -204,6 +209,7 @@ int main(int argc, char *argv[], char *envp[])
if (screenInfo.numScreens < 1)
FatalError("no screens found");
InitExtensions(argc, argv);
for (i = 0; i < screenInfo.numScreens; i++)
{
ScreenPtr pScreen = screenInfo.screens[i];
@ -314,17 +320,18 @@ int main(int argc, char *argv[], char *envp[])
FreeGCperDepth(i);
FreeDefaultStipple(i);
(* screenInfo.screens[i]->CloseScreen)(i, screenInfo.screens[i]);
dixFreePrivates(screenInfo.screens[i]->devPrivates);
dixFreePrivates(screenInfo.screens[i]->devPrivates, PRIVATE_SCREEN);
free(screenInfo.screens[i]);
screenInfo.numScreens = i;
}
dixFreePrivates(serverClient->devPrivates, PRIVATE_CLIENT);
serverClient->devPrivates = NULL;
FreeFonts();
FreeAuditTimer();
dixFreePrivates(serverClient->devPrivates);
serverClient->devPrivates = NULL;
if (dispatchException & DE_TERMINATE)
{
CloseWellKnownConnections();

View File

@ -91,6 +91,11 @@ FreeScratchPixmapHeader(PixmapPtr pPixmap)
Bool
CreateScratchPixmapsForScreen(int scrnum)
{
unsigned int pixmap_size;
pixmap_size = sizeof(PixmapRec) + dixPrivatesSize(PRIVATE_PIXMAP);
screenInfo.screens[scrnum]->totalPixmapSize = BitmapBytePad(pixmap_size * 8);
/* let it be created on first use */
screenInfo.screens[scrnum]->pScratchPixmap = NULL;
return TRUE;
@ -110,6 +115,8 @@ AllocatePixmap(ScreenPtr pScreen, int pixDataSize)
{
PixmapPtr pPixmap;
assert(pScreen->totalPixmapSize > 0);
if (pScreen->totalPixmapSize > ((size_t)-1) - pixDataSize)
return NullPixmap;
@ -117,6 +124,14 @@ AllocatePixmap(ScreenPtr pScreen, int pixDataSize)
if (!pPixmap)
return NullPixmap;
pPixmap->devPrivates = NULL;
dixInitPrivates(pPixmap, pPixmap + 1, PRIVATE_PIXMAP);
return pPixmap;
}
/* callable by ddx */
void
FreePixmap(PixmapPtr pPixmap)
{
dixFiniPrivates(pPixmap, PRIVATE_PIXMAP);
free(pPixmap);
}

View File

@ -52,6 +52,10 @@ typedef struct _PrivateDesc {
#define PRIV_MAX 256
#define PRIV_STEP 16
static int number_privates_allocated;
static int number_private_ptrs_allocated;
static int bytes_private_data_allocated;
/* list of all allocated privates */
static PrivateDescRec items[PRIV_MAX];
static int nextPriv;
@ -59,31 +63,31 @@ static int nextPriv;
static PrivateDescRec *
findItem(const DevPrivateKey key)
{
if (!*key) {
if (!key->key) {
if (nextPriv >= PRIV_MAX)
return NULL;
items[nextPriv].key = key;
*key = nextPriv;
key->key = nextPriv;
nextPriv++;
}
return items + *key;
return items + key->key;
}
static _X_INLINE int
privateExists(PrivateRec **privates, const DevPrivateKey key)
{
return *key && *privates &&
(*privates)[0].state > *key &&
(*privates)[*key].state;
return key->key && *privates &&
(*privates)[0].state > key->key &&
(*privates)[key->key].state;
}
/*
* Request pre-allocated space.
*/
int
dixRequestPrivate(const DevPrivateKey key, unsigned size)
dixRegisterPrivateKey(const DevPrivateKey key, DevPrivateType type, unsigned size)
{
PrivateDescRec *item = findItem(key);
if (!item)
@ -96,7 +100,7 @@ dixRequestPrivate(const DevPrivateKey key, unsigned size)
/*
* Allocate a private and attach it to an existing object.
*/
pointer *
static pointer *
dixAllocatePrivate(PrivateRec **privates, const DevPrivateKey key)
{
PrivateDescRec *item = findItem(key);
@ -104,7 +108,7 @@ dixAllocatePrivate(PrivateRec **privates, const DevPrivateKey key)
pointer value;
int oldsize, newsize;
newsize = (*key / PRIV_STEP + 1) * PRIV_STEP;
newsize = (key->key / PRIV_STEP + 1) * PRIV_STEP;
/* resize or init privates array */
if (!item)
@ -112,6 +116,8 @@ dixAllocatePrivate(PrivateRec **privates, const DevPrivateKey key)
/* initialize privates array if necessary */
if (!*privates) {
++number_privates_allocated;
number_private_ptrs_allocated += newsize;
ptr = calloc(newsize, sizeof(*ptr));
if (!ptr)
return NULL;
@ -122,22 +128,25 @@ dixAllocatePrivate(PrivateRec **privates, const DevPrivateKey key)
oldsize = (*privates)[0].state;
/* resize privates array if necessary */
if (*key >= oldsize) {
if (key->key >= oldsize) {
ptr = realloc(*privates, newsize * sizeof(*ptr));
if (!ptr)
return NULL;
memset(ptr + oldsize, 0, (newsize - oldsize) * sizeof(*ptr));
*privates = ptr;
(*privates)[0].state = newsize;
number_private_ptrs_allocated -= oldsize;
number_private_ptrs_allocated += newsize;
}
/* initialize slot */
ptr = *privates + *key;
ptr = *privates + key->key;
ptr->state = 1;
if (item->size) {
value = calloc(item->size, 1);
if (!value)
return NULL;
bytes_private_data_allocated += item->size;
ptr->value = value;
}
@ -152,8 +161,9 @@ dixLookupPrivate(PrivateRec **privates, const DevPrivateKey key)
{
pointer *ptr;
assert (key->key != 0);
if (privateExists(privates, key))
return (*privates)[*key].value;
return (*privates)[key->key].value;
ptr = dixAllocatePrivate(privates, key);
return ptr ? *ptr : NULL;
@ -165,8 +175,10 @@ dixLookupPrivate(PrivateRec **privates, const DevPrivateKey key)
pointer *
dixLookupPrivateAddr(PrivateRec **privates, const DevPrivateKey key)
{
assert (key->key != 0);
if (privateExists(privates, key))
return &(*privates)[*key].value;
return &(*privates)[key->key].value;
return dixAllocatePrivate(privates, key);
}
@ -177,9 +189,10 @@ dixLookupPrivateAddr(PrivateRec **privates, const DevPrivateKey key)
int
dixSetPrivate(PrivateRec **privates, const DevPrivateKey key, pointer val)
{
assert (key->key != 0);
top:
if (privateExists(privates, key)) {
(*privates)[*key].value = val;
(*privates)[key->key].value = val;
return TRUE;
}
@ -192,17 +205,21 @@ dixSetPrivate(PrivateRec **privates, const DevPrivateKey key, pointer val)
* Called to free privates at object deletion time.
*/
void
dixFreePrivates(PrivateRec *privates)
dixFreePrivates(PrivateRec *privates, DevPrivateType type)
{
int i;
if (privates)
if (privates) {
number_private_ptrs_allocated -= privates->state;
number_privates_allocated--;
for (i = 1; i < privates->state; i++)
if (privates[i].state) {
/* free pre-allocated memory */
if (items[i].size)
free(privates[i].value);
bytes_private_data_allocated -= items[i].size;
}
}
free(privates);
}
@ -239,16 +256,32 @@ dixLookupPrivateOffset(RESTYPE type)
return -1;
}
int
void
dixPrivateUsage(void)
{
ErrorF("number of private structures: %d\n",
number_privates_allocated);
ErrorF("total number of private pointers: %d (%zd bytes)\n",
number_private_ptrs_allocated,
number_private_ptrs_allocated * sizeof (struct _Private));
ErrorF("bytes of extra private data: %d\n",
bytes_private_data_allocated);
ErrorF("Total privates memory usage: %zd\n",
bytes_private_data_allocated +
number_private_ptrs_allocated * sizeof (struct _Private));
}
void
dixResetPrivates(void)
{
int i;
/* reset private descriptors */
for (i = 1; i < nextPriv; i++) {
*items[i].key = 0;
items[i].key->key = 0;
items[i].size = 0;
}
nextPriv = 1;
return TRUE;
if (number_privates_allocated)
dixPrivateUsage();
}

View File

@ -269,13 +269,13 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property,
{
if (!pWin->optional && !MakeWindowOptional (pWin))
return(BadAlloc);
pProp = malloc(sizeof(PropertyRec));
pProp = dixAllocateObjectWithPrivates(PropertyRec, PRIVATE_PROPERTY);
if (!pProp)
return(BadAlloc);
data = malloc(totalSize);
if (!data && len)
{
free(pProp);
dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY);
return(BadAlloc);
}
memcpy(data, value, totalSize);
@ -289,7 +289,7 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property,
DixCreateAccess|DixWriteAccess);
if (rc != Success) {
free(data);
free(pProp);
dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY);
pClient->errorValue = property;
return rc;
}
@ -405,9 +405,8 @@ DeleteProperty(ClientPtr client, WindowPtr pWin, Atom propName)
}
deliverPropertyNotifyEvent(pWin, PropertyDelete, pProp->propertyName);
dixFreePrivates(pProp->devPrivates);
free(pProp->data);
free(pProp);
dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY);
}
return rc;
}
@ -422,9 +421,8 @@ DeleteAllWindowProperties(WindowPtr pWin)
{
deliverPropertyNotifyEvent(pWin, PropertyDelete, pProp->propertyName);
pNextProp = pProp->next;
dixFreePrivates(pProp->devPrivates);
free(pProp->data);
free(pProp);
dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY);
pProp = pNextProp;
}
}
@ -570,9 +568,8 @@ ProcGetProperty(ClientPtr client)
prevProp->next = pProp->next;
}
dixFreePrivates(pProp->devPrivates);
free(pProp->data);
free(pProp);
dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY);
}
return Success;
}

View File

@ -94,8 +94,7 @@ InitSelections(void)
pSel = CurrentSelections;
while (pSel) {
pNextSel = pSel->next;
dixFreePrivates(pSel->devPrivates);
free(pSel);
dixFreeObjectWithPrivates(pSel, PRIVATE_SELECTION);
pSel = pNextSel;
}

View File

@ -151,12 +151,8 @@ WindowSeekDeviceCursor(WindowPtr pWin,
int screenIsSaved = SCREEN_SAVER_OFF;
static int FocusPrivatesKeyIndex;
DevPrivateKey FocusPrivatesKey = &FocusPrivatesKeyIndex;
static Bool TileScreenSaver(ScreenPtr pScreen, int kind);
#define INPUTONLY_LEGAL_MASK (CWWinGravity | CWEventMask | \
CWDontPropagate | CWOverrideRedirect | CWCursor )
@ -357,7 +353,7 @@ CreateRootWindow(ScreenPtr pScreen)
BoxRec box;
PixmapFormatRec *format;
pWin = malloc(sizeof(WindowRec));
pWin = dixAllocateObjectWithPrivates(WindowRec, PRIVATE_WINDOW);
if (!pWin)
return FALSE;
@ -370,7 +366,6 @@ CreateRootWindow(ScreenPtr pScreen)
pWin->drawable.pScreen = pScreen;
pWin->drawable.type = DRAWABLE_WINDOW;
pWin->devPrivates = NULL;
pWin->drawable.depth = pScreen->rootDepth;
for (format = screenInfo.formats;
@ -637,14 +632,13 @@ CreateWindow(Window wid, WindowPtr pParent, int x, int y, unsigned w,
return NullWindow;
}
pWin = malloc(sizeof(WindowRec));
pWin = dixAllocateObjectWithPrivates(WindowRec, PRIVATE_WINDOW);
if (!pWin)
{
*error = BadAlloc;
return NullWindow;
}
pWin->drawable = pParent->drawable;
pWin->devPrivates = NULL;
pWin->drawable.depth = depth;
if (depth == pParent->drawable.depth)
pWin->drawable.bitsPerPixel = pParent->drawable.bitsPerPixel;
@ -668,7 +662,7 @@ CreateWindow(Window wid, WindowPtr pParent, int x, int y, unsigned w,
{
if (!MakeWindowOptional (pWin))
{
free(pWin);
dixFreeObjectWithPrivates(pWin, PRIVATE_WINDOW);
*error = BadAlloc;
return NullWindow;
}
@ -683,7 +677,7 @@ CreateWindow(Window wid, WindowPtr pParent, int x, int y, unsigned w,
*error = XaceHook(XACE_RESOURCE_ACCESS, client, wid, RT_WINDOW, pWin,
RT_WINDOW, pWin->parent, DixCreateAccess|DixSetAttrAccess);
if (*error != Success) {
free(pWin);
dixFreeObjectWithPrivates(pWin, PRIVATE_WINDOW);
return NullWindow;
}
@ -881,8 +875,7 @@ CrushTree(WindowPtr pWin)
(*UnrealizeWindow)(pChild);
}
FreeWindowResources(pChild);
dixFreePrivates(pChild->devPrivates);
free(pChild);
dixFreeObjectWithPrivates(pChild, PRIVATE_WINDOW);
if ( (pChild = pSib) )
break;
pChild = pParent;
@ -932,9 +925,7 @@ DeleteWindow(pointer value, XID wid)
if (pWin->prevSib)
pWin->prevSib->nextSib = pWin->nextSib;
}
free(dixLookupPrivate(&pWin->devPrivates, FocusPrivatesKey));
dixFreePrivates(pWin->devPrivates);
free(pWin);
dixFreeObjectWithPrivates(pWin, PRIVATE_WINDOW);
return Success;
}

View File

@ -37,12 +37,12 @@
#include "exa_priv.h"
#include "exa.h"
static int exaScreenPrivateKeyIndex;
DevPrivateKey exaScreenPrivateKey = &exaScreenPrivateKeyIndex;
static int exaPixmapPrivateKeyIndex;
DevPrivateKey exaPixmapPrivateKey = &exaPixmapPrivateKeyIndex;
static int exaGCPrivateKeyIndex;
DevPrivateKey exaGCPrivateKey = &exaGCPrivateKeyIndex;
static DevPrivateKeyRec exaScreenPrivateKeyRec;
#define exaScreenPrivateKey (&exaScreenPrivateKeyRec)
static DevPrivateKeyRec exaPixmapPrivateKeyRec;
#define exaPixmapPrivateKey (&exaPixmapPrivateKeyRec)
static DevPrivateKeyRec exaGCPrivateKeyRec;
#define exaGCPrivateKey (&exaGCPrivateKeyRec)
#ifdef MITSHM
static ShmFuncs exaShmFuncs = { NULL, NULL };
@ -889,7 +889,13 @@ exaDriverInit (ScreenPtr pScreen,
ps = GetPictureScreenIfSet(pScreen);
pExaScr = calloc(sizeof (ExaScreenPrivRec), 1);
if (!dixRegisterPrivateKey(&exaScreenPrivateKeyRec, PRIVATE_SCREEN, 0)) {
LogMessage(X_WARNING, "EXA(%d): Failed to register screen private\n",
pScreen->myNum);
return FALSE;
}
pExaScr = calloc (sizeof (ExaScreenPrivRec), 1);
if (!pExaScr) {
LogMessage(X_WARNING, "EXA(%d): Failed to allocate screen private\n",
pScreen->myNum);
@ -904,7 +910,7 @@ exaDriverInit (ScreenPtr pScreen,
exaDDXDriverInit(pScreen);
if (!dixRequestPrivate(exaGCPrivateKey, sizeof(ExaGCPrivRec))) {
if (!dixRegisterPrivateKey(&exaGCPrivateKeyRec, PRIVATE_GC, sizeof(ExaGCPrivRec))) {
LogMessage(X_WARNING,
"EXA(%d): Failed to allocate GC private\n",
pScreen->myNum);
@ -953,7 +959,7 @@ exaDriverInit (ScreenPtr pScreen,
*/
if (pExaScr->info->flags & EXA_OFFSCREEN_PIXMAPS)
{
if (!dixRequestPrivate(exaPixmapPrivateKey, sizeof(ExaPixmapPrivRec))) {
if (!dixRegisterPrivateKey(&exaPixmapPrivateKeyRec, PRIVATE_PIXMAP, sizeof(ExaPixmapPrivRec))) {
LogMessage(X_WARNING,
"EXA(%d): Failed to allocate pixmap private\n",
pScreen->myNum);

19
fb/fb.h
View File

@ -603,8 +603,12 @@ extern _X_EXPORT void fbSetBits (FbStip *bits, int stride, FbStip data);
} \
}
extern _X_EXPORT DevPrivateKey fbGetGCPrivateKey(void);
extern _X_EXPORT DevPrivateKey fbGetWinPrivateKey(void);
extern _X_EXPORT DevPrivateKey
fbGetGCPrivateKey (void);
extern _X_EXPORT DevPrivateKey
fbGetWinPrivateKey (void);
extern _X_EXPORT const GCOps fbGCOps;
extern _X_EXPORT const GCFuncs fbGCFuncs;
@ -639,7 +643,8 @@ typedef void (*FinishWrapProcPtr)(DrawablePtr pDraw);
#ifdef FB_SCREEN_PRIVATE
extern _X_EXPORT DevPrivateKey fbGetScreenPrivateKey(void);
extern _X_EXPORT DevPrivateKey
fbGetScreenPrivateKey(void);
/* private field of a screen */
typedef struct {
@ -652,7 +657,7 @@ typedef struct {
} FbScreenPrivRec, *FbScreenPrivPtr;
#define fbGetScreenPrivate(pScreen) ((FbScreenPrivPtr) \
dixLookupPrivate(&(pScreen)->devPrivates, fbGetScreenPrivateKey()))
dixLookupPrivate(&(pScreen)->devPrivates, fbGetScreenPrivateKey()))
#endif
/* private field of GC */
@ -667,7 +672,7 @@ typedef struct {
} FbGCPrivRec, *FbGCPrivPtr;
#define fbGetGCPrivate(pGC) ((FbGCPrivPtr)\
dixLookupPrivate(&(pGC)->devPrivates, fbGetGCPrivateKey()))
dixLookupPrivate(&(pGC)->devPrivates, fbGetGCPrivateKey()))
#define fbGetCompositeClip(pGC) ((pGC)->pCompositeClip)
#define fbGetExpose(pGC) ((pGC)->fExpose)
@ -676,7 +681,7 @@ typedef struct {
#define fbGetScreenPixmap(s) ((PixmapPtr) (s)->devPrivate)
#define fbGetWindowPixmap(pWin) ((PixmapPtr)\
dixLookupPrivate(&((WindowPtr)(pWin))->devPrivates, fbGetWinPrivateKey()))
dixLookupPrivate(&((WindowPtr)(pWin))->devPrivates, fbGetWinPrivateKey()))
#ifdef ROOTLESS
#define __fbPixDrawableX(pPix) ((pPix)->drawable.x)
@ -830,8 +835,6 @@ fb24_32ModifyPixmapHeader (PixmapPtr pPixmap,
/*
* fballpriv.c
*/
extern _X_EXPORT DevPrivateKey fbGetWinPrivateKey(void);
extern _X_EXPORT Bool
fbAllocatePrivates(ScreenPtr pScreen, DevPrivateKey *pGCIndex);

View File

@ -27,46 +27,34 @@
#include "fb.h"
#ifdef FB_SCREEN_PRIVATE
static int fbScreenPrivateKeyIndex;
static DevPrivateKey fbScreenPrivateKey = &fbScreenPrivateKeyIndex;
DevPrivateKey fbGetScreenPrivateKey(void)
{
return fbScreenPrivateKey;
}
static DevPrivateKeyRec fbScreenPrivateKeyRec;
DevPrivateKey
fbGetScreenPrivateKey(void) { return &fbScreenPrivateKeyRec; }
#endif
static int fbGCPrivateKeyIndex;
static DevPrivateKey fbGCPrivateKey = &fbGCPrivateKeyIndex;
DevPrivateKey fbGetGCPrivateKey(void)
{
return fbGCPrivateKey;
}
static DevPrivateKeyRec fbGCPrivateKeyRec;
DevPrivateKey
fbGetGCPrivateKey (void) { return &fbGCPrivateKeyRec; }
static int fbWinPrivateKeyIndex;
static DevPrivateKey fbWinPrivateKey = &fbWinPrivateKeyIndex;
DevPrivateKey fbGetWinPrivateKey(void)
{
return fbWinPrivateKey;
}
static DevPrivateKeyRec fbWinPrivateKeyRec;
DevPrivateKey
fbGetWinPrivateKey (void) { return &fbWinPrivateKeyRec; }
Bool
fbAllocatePrivates(ScreenPtr pScreen, DevPrivateKey *pGCKey)
{
if (pGCKey)
*pGCKey = fbGCPrivateKey;
*pGCKey = &fbGCPrivateKeyRec;
if (!dixRequestPrivate(fbGCPrivateKey, sizeof(FbGCPrivRec)))
if (!dixRegisterPrivateKey(&fbGCPrivateKeyRec, PRIVATE_GC, sizeof(FbGCPrivRec)))
return FALSE;
#ifdef FB_SCREEN_PRIVATE
{
FbScreenPrivPtr pScreenPriv;
pScreenPriv = (FbScreenPrivPtr) malloc(sizeof (FbScreenPrivRec));
if (!pScreenPriv)
return FALSE;
dixSetPrivate(&pScreen->devPrivates, fbScreenPrivateKey, pScreenPriv);
}
if (!dixRegisterPrivateKey(&fbScreenPrivateKeyRec, PRIVATE_SCREEN, sizeof (FbScreenPrivRec)))
return FALSE;
#endif
if (!dixRegisterPrivateKey(&fbWinPrivateKeyRec, PRIVATE_WINDOW, 0))
return FALSE;
return TRUE;
}

View File

@ -36,8 +36,8 @@
#error "You should be compiling fbcmap_mi.c instead of fbcmap.c!"
#endif
static int cmapScrPrivateKeyIndex;
static DevPrivateKey cmapScrPrivateKey = &cmapScrPrivateKeyIndex;
static DevPrivateKeyRec cmapScrPrivateKeyRec;
#define cmapScrPrivateKey (&cmapScrPrivateKeyRec)
#define GetInstalledColormap(s) ((ColormapPtr) dixLookupPrivate(&(s)->devPrivates, cmapScrPrivateKey))
#define SetInstalledColormap(s,c) (dixSetPrivate(&(s)->devPrivates, cmapScrPrivateKey, c))

View File

@ -33,8 +33,8 @@
#include "fboverlay.h"
#include "shmint.h"
static int fbOverlayScreenPrivateKeyIndex;
static DevPrivateKey fbOverlayScreenPrivateKey = &fbOverlayScreenPrivateKeyIndex;
static DevPrivateKeyRec fbOverlayScreenPrivateKeyRec;
#define fbOverlayScreenPrivateKey (&fbOverlayScreenPrivateKeyRec)
DevPrivateKey fbOverlayGetScreenPrivateKey(void)
{
@ -348,6 +348,9 @@ fbOverlayFinishScreenInit(ScreenPtr pScreen,
VisualID defaultVisual;
FbOverlayScrPrivPtr pScrPriv;
if (!dixRegisterPrivateKey(&fbOverlayScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
pScrPriv = malloc(sizeof (FbOverlayScrPrivRec));
if (!pScrPriv)
return FALSE;
@ -416,7 +419,6 @@ fbOverlayFinishScreenInit(ScreenPtr pScreen,
pScrPriv->layer[1].u.init.pbits = pbits2;
pScrPriv->layer[1].u.init.width = width2;
pScrPriv->layer[1].u.init.depth = depth2;
dixSetPrivate(&pScreen->devPrivates, fbOverlayScreenPrivateKey, pScrPriv);
/* overwrite miCloseScreen with our own */

View File

@ -67,6 +67,7 @@ fbCreatePixmapBpp (ScreenPtr pScreen, int width, int height, int depth, int bpp,
pPixmap->devKind = paddedWidth;
pPixmap->refcnt = 1;
pPixmap->devPrivate.ptr = (pointer) ((char *)pPixmap + base + adjust);
#ifdef FB_DEBUG
pPixmap->devPrivate.ptr = (void *) ((char *) pPixmap->devPrivate.ptr + paddedWidth);
fbInitializeDrawable (&pPixmap->drawable);
@ -100,8 +101,7 @@ fbDestroyPixmap (PixmapPtr pPixmap)
{
if(--pPixmap->refcnt)
return TRUE;
dixFreePrivates(pPixmap->devPrivates);
free(pPixmap);
FreePixmap(pPixmap);
return TRUE;
}

View File

@ -37,9 +37,6 @@ fbCloseScreen (int index, ScreenPtr pScreen)
free(depths);
free(pScreen->visuals);
free(pScreen->devPrivate);
#ifdef FB_SCREEN_PRIVATE
free(dixLookupPrivate(&pScreen->devPrivates, fbGetScreenPrivateKey()));
#endif
return TRUE;
}

View File

@ -83,13 +83,14 @@
#define fbFixCoordModePrevious wfbFixCoordModePrevious
#define fbGCFuncs wfbGCFuncs
#define fbGCOps wfbGCOps
#define fbGCPrivateKey wfbGCPrivateKey
#define fbGCPrivateKeyRec wfbGCPrivateKeyRec
#define fbGeneration wfbGeneration
#define fbGetGCPrivateKey wfbGetGCPrivateKey
#define fbGetImage wfbGetImage
#define fbGetScreenPrivateKey wfbGetScreenPrivateKey
#define fbGetSpans wfbGetSpans
#define _fbGetWindowPixmap _wfbGetWindowPixmap
#define fbWinPrivateKeyRec wfbWinPrivateKeyRec
#define fbGetWinPrivateKey wfbGetWinPrivateKey
#define fbGlyph16 wfbGlyph16
#define fbGlyph24 wfbGlyph24
@ -118,7 +119,6 @@
#define fbOverlayGeneration wfbOverlayGeneration
#define fbOverlayGetScreenPrivateKey wfbOverlayGetScreenPrivateKey
#define fbOverlayPaintKey wfbOverlayPaintKey
#define fbOverlayScreenPrivateKey wfbOverlayScreenPrivateKey
#define fbOverlaySetupScreen wfbOverlaySetupScreen
#define fbOverlayUpdateLayerRegion wfbOverlayUpdateLayerRegion
#define fbOverlayWindowExposures wfbOverlayWindowExposures
@ -157,7 +157,7 @@
#define fbResolveColor wfbResolveColor
#define fbRestoreAreas wfbRestoreAreas
#define fbSaveAreas wfbSaveAreas
#define fbScreenPrivateKey wfbScreenPrivateKey
#define fbScreenPrivateKeyRec wfbScreenPrivateKeyRec
#define fbSegment wfbSegment
#define fbSelectBres wfbSelectBres
#define fbSetSpans wfbSetSpans
@ -182,7 +182,7 @@
#define fbUnrealizeFont wfbUnrealizeFont
#define fbValidateGC wfbValidateGC
#define fbWalkCompositeRegion wfbWalkCompositeRegion
#define fbWinPrivateKey wfbWinPrivateKey
#define fbWinPrivateKeyRec wfbWinPrivateKeyRec
#define fbZeroLine wfbZeroLine
#define fbZeroSegment wfbZeroSegment
#define free_pixman_pict wfb_free_pixman_pict

View File

@ -65,8 +65,8 @@ RESTYPE __glXSwapBarrierRes;
*/
xGLXSingleReply __glXReply;
static int glxClientPrivateKeyIndex;
static DevPrivateKey glxClientPrivateKey = &glxClientPrivateKeyIndex;
static DevPrivateKeyRec glxClientPrivateKeyRec;
#define glxClientPrivateKey (&glxClientPrivateKeyRec)
/*
** Client that called into GLX dispatch.
@ -364,7 +364,7 @@ void GlxExtensionInit(void)
if (!__glXContextRes || !__glXDrawableRes || !__glXSwapBarrierRes)
return;
if (!dixRequestPrivate(glxClientPrivateKey, sizeof (__GLXclientState)))
if (!dixRegisterPrivateKey(&glxClientPrivateKeyRec, PRIVATE_CLIENT, sizeof (__GLXclientState)))
return;
if (!AddCallback (&ClientStateCallback, glxClientCallback, 0))
return;

View File

@ -44,8 +44,8 @@
#include "glxext.h"
#include "protocol-versions.h"
static int glxScreenPrivateKeyIndex;
static DevPrivateKey glxScreenPrivateKey = &glxScreenPrivateKeyIndex;
static DevPrivateKeyRec glxScreenPrivateKeyRec;
#define glxScreenPrivateKey (&glxScreenPrivateKeyRec)
const char GLServerVersion[] = "1.4";
static const char GLServerExtensions[] =
@ -352,6 +352,9 @@ void __glXScreenInit(__GLXscreen *pGlxScreen, ScreenPtr pScreen)
__GLXconfig *config;
int i;
if (!dixRegisterPrivateKey(&glxScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
return;
pGlxScreen->pScreen = pScreen;
pGlxScreen->GLextensions = xstrdup(GLServerExtensions);
pGlxScreen->GLXvendor = xstrdup(GLXServerVendorName);

View File

@ -364,4 +364,27 @@ do { \
#define MAXSCREENSCALLOC_FATAL(o,m) _MAXSCREENSALLOCF(o,MAXSCREENS*(m),1)
#endif
extern DevPrivateKeyRec dmxGCPrivateKeyRec;
#define dmxGCPrivateKey (&dmxGCPrivateKeyRec) /**< Private index for GCs */
extern DevPrivateKeyRec dmxWinPrivateKeyRec;
#define dmxWinPrivateKey (&dmxWinPrivateKeyRec) /**< Private index for Windows */
extern DevPrivateKeyRec dmxPixPrivateKeyRec;
#define dmxPixPrivateKey (&dmxPixPrivateKeyRec) /**< Private index for Pixmaps */
extern int dmxFontPrivateIndex; /**< Private index for Fonts */
extern DevPrivateKeyRec dmxScreenPrivateKeyRec;
#define dmxScreenPrivateKey (&dmxScreenPrivateKeyRec) /**< Private index for Screens */
extern DevPrivateKeyRec dmxColormapPrivateKeyRec;
#define dmxColormapPrivateKey (&dmxColormapPrivateKeyRec) /**< Private index for Colormaps */
extern DevPrivateKeyRec dmxPictPrivateKeyRec;
#define dmxPictPrivateKey (&dmxPictPrivateKeyRec) /**< Private index for Picts */
extern DevPrivateKeyRec dmxGlyphSetPrivateKeyRec;
#define dmxGlyphSetPrivateKey (&dmxGlyphSetPrivateKeyRec) /**< Private index for GlyphSets */
#endif /* DMX_H */

View File

@ -55,9 +55,6 @@ extern Bool dmxCreateDefColormap(ScreenPtr pScreen);
extern Bool dmxBECreateColormap(ColormapPtr pColormap);
extern Bool dmxBEFreeColormap(ColormapPtr pColormap);
/** Private index. \see dmxcmap.c \see dmxscrinit.c \see dmxwindow.c */
extern DevPrivateKey dmxColormapPrivateKey;
/** Set colormap private structure. */
#define DMX_SET_COLORMAP_PRIV(_pCMap, _pCMapPriv) \
dixSetPrivate(&(_pCMap)->devPrivates, dmxColormapPrivateKey, _pCMapPriv)

View File

@ -85,7 +85,7 @@ static GCOps dmxGCOps = {
/** Initialize the GC on \a pScreen */
Bool dmxInitGC(ScreenPtr pScreen)
{
if (!dixRequestPrivate(dmxGCPrivateKey, sizeof(dmxGCPrivRec)))
if (!dixRegisterPrivateKey(&dmxGCPrivateKeyRec, PRIVATE_GC, sizeof(dmxGCPrivRec)))
return FALSE;
return TRUE;
}

View File

@ -63,9 +63,6 @@ extern void dmxCopyClip(GCPtr pGCDst, GCPtr pGCSrc);
extern void dmxBECreateGC(ScreenPtr pScreen, GCPtr pGC);
extern Bool dmxBEFreeGC(GCPtr pGC);
/** Private index. \see dmxgc.c \see dmxscrinit.c */
extern DevPrivateKey dmxGCPrivateKey;
/** Get private. */
#define DMX_GET_GC_PRIV(_pGC) \
(dmxGCPrivPtr)dixLookupPrivate(&(_pGC)->devPrivates, dmxGCPrivateKey)

View File

@ -145,7 +145,7 @@ Bool dmxPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats)
if (!miPictureInit(pScreen, formats, nformats))
return FALSE;
if (!dixRequestPrivate(dmxPictPrivateKey, sizeof(dmxPictPrivRec)))
if (!dixRegisterPrivateKey(&dmxPictPrivateKeyRec, PRIVATE_PICTURE, sizeof(dmxPictPrivRec)))
return FALSE;
ps = GetPictureScreen(pScreen);

View File

@ -116,10 +116,6 @@ extern Bool dmxBEFreeGlyphSet(ScreenPtr pScreen, GlyphSetPtr glyphSet);
extern int dmxBECreatePicture(PicturePtr pPicture);
extern Bool dmxBEFreePicture(PicturePtr pPicture);
extern DevPrivateKey dmxPictPrivateKey; /**< Index for picture private data */
extern DevPrivateKey dmxGlyphSetPrivateKey; /**< Index for glyphset private data */
/** Get the picture private data given a picture pointer */
#define DMX_GET_PICT_PRIV(_pPict) \
(dmxPictPrivPtr)dixLookupPrivate(&(_pPict)->devPrivates, dmxPictPrivateKey)

View File

@ -49,7 +49,7 @@
/** Initialize a private area in \a pScreen for pixmap information. */
Bool dmxInitPixmap(ScreenPtr pScreen)
{
if (!dixRequestPrivate(dmxPixPrivateKey, sizeof(dmxPixPrivRec)))
if (!dixRegisterPrivateKey(&dmxPixPrivateKeyRec, PRIVATE_PIXMAP, sizeof(dmxPixPrivRec)))
return FALSE;
return TRUE;
@ -174,8 +174,7 @@ Bool dmxDestroyPixmap(PixmapPtr pPixmap)
dmxSync(dmxScreen, FALSE);
}
}
dixFreePrivates(pPixmap->devPrivates);
free(pPixmap);
FreePixmap(pPixmap);
#if 0
if (pScreen->DestroyPixmap)

View File

@ -57,9 +57,6 @@ extern RegionPtr dmxBitmapToRegion(PixmapPtr pPixmap);
extern void dmxBECreatePixmap(PixmapPtr pPixmap);
extern Bool dmxBEFreePixmap(PixmapPtr pPixmap);
/** Private index. \see dmxpicmap.h \see dmxscrinit.c */
extern DevPrivateKey dmxPixPrivateKey;
/** Get pixmap private pointer. */
#define DMX_GET_PIXMAP_PRIV(_pPix) \
(dmxPixPrivPtr)dixLookupPrivate(&(_pPix)->devPrivates, dmxPixPrivateKey)

View File

@ -65,21 +65,14 @@ static Bool dmxSaveScreen(ScreenPtr pScreen, int what);
static unsigned long dmxGeneration;
static unsigned long *dmxCursorGeneration;
static int dmxGCPrivateKeyIndex;
DevPrivateKey dmxGCPrivateKey = &dmxGCPrivateKeyIndex; /**< Private index for GCs */
static int dmxWinPrivateKeyIndex;
DevPrivateKey dmxWinPrivateKey = &dmxWinPrivateKeyIndex; /**< Private index for Windows */
static int dmxPixPrivateKeyIndex;
DevPrivateKey dmxPixPrivateKey = &dmxPixPrivateKeyIndex; /**< Private index for Pixmaps */
DevPrivateKeyRec dmxGCPrivateKeyRec;
DevPrivateKeyRec dmxWinPrivateKeyRec;
DevPrivateKeyRec dmxPixPrivateKeyRec;
int dmxFontPrivateIndex; /**< Private index for Fonts */
static int dmxScreenPrivateKeyIndex;
DevPrivateKey dmxScreenPrivateKey = &dmxScreenPrivateKeyIndex; /**< Private index for Screens */
static int dmxColormapPrivateKeyIndex;
DevPrivateKey dmxColormapPrivateKey = &dmxColormapPrivateKeyIndex; /**< Private index for Colormaps */
static int dmxPictPrivateKeyIndex;
DevPrivateKey dmxPictPrivateKey = &dmxPictPrivateKeyIndex; /**< Private index for Picts */
static int dmxGlyphSetPrivateKeyIndex;
DevPrivateKey dmxGlyphSetPrivateKey = &dmxGlyphSetPrivateKeyIndex; /**< Private index for GlyphSets */
DevPrivateKeyRec dmxScreenPrivateKeyRec;
DevPrivateKeyRec dmxColormapPrivateKeyRec;
DevPrivateKeyRec dmxPictPrivateKeyRec;
DevPrivateKeyRec dmxGlyphSetPrivateKeyRec;
/** Initialize the parts of screen \a idx that require access to the
* back-end server. */
@ -210,6 +203,13 @@ Bool dmxScreenInit(int idx, ScreenPtr pScreen, int argc, char *argv[])
DMXScreenInfo *dmxScreen = &dmxScreens[idx];
int i, j;
if (!dixRegisterPrivateKey(&dmxScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if (!dixRegisterPrivateKey(&dmxColormapPrivateKeyRec, PRIVATE_COLORMAP, 0))
return FALSE;
if (!dixRegisterPrivateKey(&dmxGlyphSetPrivateKeyRec, PRIVATE_GLYPHSET, 0))
return FALSE;
if (dmxGeneration != serverGeneration) {
/* Allocate font private index */
dmxFontPrivateIndex = AllocateFontPrivateIndex();

View File

@ -40,9 +40,6 @@
#include "scrnintstr.h"
/** Private index. \see dmxscrrinit.c \see input/dmxconcole.c */
extern DevPrivateKey dmxScreenPrivateKey;
extern Bool dmxScreenInit(int idx, ScreenPtr pScreen, int argc, char *argv[]);
extern void dmxBEScreenInit(int idx, ScreenPtr pScreen);

View File

@ -60,7 +60,7 @@ static void dmxDoSetShape(WindowPtr pWindow);
/** Initialize the private area for the window functions. */
Bool dmxInitWindow(ScreenPtr pScreen)
{
if (!dixRequestPrivate(dmxWinPrivateKey, sizeof(dmxWinPrivRec)))
if (!dixRegisterPrivateKey(&dmxWinPrivateKeyRec, PRIVATE_WINDOW, sizeof(dmxWinPrivRec)))
return FALSE;
return TRUE;

View File

@ -96,9 +96,6 @@ extern Bool dmxBEDestroyWindow(WindowPtr pWindow);
/* Support for shape extension */
extern void dmxSetShape(WindowPtr pWindow, int kind);
/** Private index. \see dmxwindow.c \see dmxscrinit.c */
extern DevPrivateKey dmxWinPrivateKey;
/** Get window private pointer. */
#define DMX_GET_WINDOW_PRIV(_pWin) ((dmxWinPrivPtr) \
dixLookupPrivate(&(_pWin)->devPrivates, dmxWinPrivateKey))

View File

@ -109,10 +109,10 @@ static Bool findWindowPairFromLocal (WindowPtr a_local,
static unsigned char DRIReqCode = 0;
static int ephyrDRIWindowKeyIndex;
static DevPrivateKey ephyrDRIWindowKey = &ephyrDRIWindowKeyIndex;
static int ephyrDRIScreenKeyIndex;
static DevPrivateKey ephyrDRIScreenKey = &ephyrDRIScreenKeyIndex;
static DevPrivateKeyRec ephyrDRIWindowKeyRec;
#define ephyrDRIWindowKey (&ephyrDRIWindowKeyRec)
static DevPrivateKeyRec ephyrDRIScreenKeyRec;
#define ephyrDRIScreenKey (&ephyrDRIScreenKeyRec)
#define GET_EPHYR_DRI_WINDOW_PRIV(win) ((EphyrDRIWindowPrivPtr) \
dixLookupPrivate(&(win)->devPrivates, ephyrDRIWindowKey))

View File

@ -64,8 +64,7 @@ KdDepths kdDepths[] = {
#define KD_DEFAULT_BUTTONS 5
static int kdScreenPrivateKeyIndex;
DevPrivateKey kdScreenPrivateKey = &kdScreenPrivateKeyIndex;
DevPrivateKeyRec kdScreenPrivateKeyRec;
unsigned long kdGeneration;
Bool kdVideoTest;
@ -699,6 +698,9 @@ KdAllocatePrivates (ScreenPtr pScreen)
if (kdGeneration != serverGeneration)
kdGeneration = serverGeneration;
if (!dixRegisterPrivateKey(&kdScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
pScreenPriv = calloc(1, sizeof (*pScreenPriv));
if (!pScreenPriv)
return FALSE;

View File

@ -342,7 +342,9 @@ typedef struct _KdPointerMatrix {
(PixmapWidthPaddingInfo[d].padRoundUp+1)))
#endif
extern DevPrivateKey kdScreenPrivateKey;
extern DevPrivateKeyRec kdScreenPrivateKeyRec;
#define kdScreenPrivateKey (&kdScreenPrivateKeyRec)
extern unsigned long kdGeneration;
extern Bool kdEnabled;
extern Bool kdSwitchPending;

View File

@ -103,10 +103,10 @@ static void KdXVClipNotify(WindowPtr pWin, int dx, int dy);
/* misc */
static Bool KdXVInitAdaptors(ScreenPtr, KdVideoAdaptorPtr*, int);
static int KdXVWindowKeyIndex;
DevPrivateKey KdXVWindowKey = &KdXVWindowKeyIndex;
static int KdXvScreenKeyIndex;
DevPrivateKey KdXvScreenKey = &KdXvScreenKeyIndex;
static DevPrivateKeyRec KdXVWindowKeyRec;
#define KdXVWindowKey (&KdXVWindowKeyRec)
static DevPrivateKeyRec KdXvScreenKeyRec;
#define KdXvScreenKey (&KdXvScreenKeyRec)
static unsigned long KdXVGeneration = 0;
static unsigned long PortResource = 0;
@ -199,6 +199,12 @@ KdXVScreenInit(
if(!XvGetScreenKeyProc || !XvGetRTPortProc || !XvScreenInitProc)
return FALSE;
if (!dixRegisterPrivateKey(&KdXVWindowKeyRec, PRIVATE_WINDOW, 0))
return FALSE;
if (!dixRegisterPrivateKey(&KdXVScreenKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if(Success != (*XvScreenInitProc)(pScreen)) return FALSE;
KdXvScreenKey = (*XvGetScreenKeyProc)();

View File

@ -389,8 +389,8 @@ ddxProcessArgument(int argc, char *argv[], int i)
return 0;
}
static int cmapScrPrivateKeyIndex;
static DevPrivateKey cmapScrPrivateKey = &cmapScrPrivateKeyIndex;
static DevPrivateKeyRec cmapScrPrivateKeyRec;
#define cmapScrPrivateKey (&cmapScrPrivateKeyRec)
#define GetInstalledColormap(s) ((ColormapPtr) dixLookupPrivate(&(s)->devPrivates, cmapScrPrivateKey))
#define SetInstalledColormap(s,c) (dixSetPrivate(&(s)->devPrivates, cmapScrPrivateKey, c))
@ -811,6 +811,9 @@ vfbScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
int ret;
char *pbits;
if (!dixRegisterPrivateKey(&cmapScrPrivateKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if (dpix == 0)
dpix = 100;

View File

@ -55,9 +55,16 @@
extern _X_EXPORT int xf86DoConfigure;
extern _X_EXPORT int xf86DoShowOptions;
extern _X_EXPORT Bool xf86DoConfigurePass1;
extern _X_EXPORT DevPrivateKey xf86ScreenKey;
extern _X_EXPORT DevPrivateKey xf86CreateRootWindowKey;
extern _X_EXPORT DevPrivateKey xf86PixmapKey;
extern _X_EXPORT DevPrivateKeyRec xf86ScreenKeyRec;
#define xf86ScreenKey (&xf86ScreenKeyRec)
extern _X_EXPORT DevPrivateKeyRec xf86CreateRootWindowKeyRec;
#define xf86CreateRootWindowKey (&xf86CreateRootWindowKeyRec)
extern _X_EXPORT DevPrivateKeyRec xf86PixmapKeyRec;
#define xf86PixmapKey (&xf86PixmapKeyRec)
extern _X_EXPORT ScrnInfoPtr *xf86Screens; /* List of pointers to ScrnInfoRecs */
extern _X_EXPORT const unsigned char byte_reversed[256];
extern _X_EXPORT Bool fbSlotClaimed;

View File

@ -51,8 +51,8 @@
#include "mi.h"
static int DGAScreenKeyIndex;
static DevPrivateKey DGAScreenKey;
static DevPrivateKeyRec DGAScreenKeyRec;
#define DGAScreenKeyRegistered dixPrivateKeyRegistered(&DGAScreenKeyRec)
static int mieq_installed = 0;
static Bool DGACloseScreen(int i, ScreenPtr pScreen);
@ -71,7 +71,7 @@ DGACopyModeInfo(
int *XDGAEventBase = NULL;
#define DGA_GET_SCREEN_PRIV(pScreen) ((DGAScreenPtr) \
dixLookupPrivate(&(pScreen)->devPrivates, DGAScreenKey))
dixLookupPrivate(&(pScreen)->devPrivates, &DGAScreenKeyRec))
typedef struct _FakedVisualList{
@ -118,7 +118,8 @@ DGAInit(
if(!modes || num <= 0)
return FALSE;
DGAScreenKey = &DGAScreenKeyIndex;
if (!dixRegisterPrivateKey(&DGAScreenKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
@ -126,7 +127,7 @@ DGAInit(
{
if(!(pScreenPriv = (DGAScreenPtr)malloc(sizeof(DGAScreenRec))))
return FALSE;
dixSetPrivate(&pScreen->devPrivates, DGAScreenKey, pScreenPriv);
dixSetPrivate(&pScreen->devPrivates, &DGAScreenKeyRec, pScreenPriv);
pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = DGACloseScreen;
pScreenPriv->DestroyColormap = pScreen->DestroyColormap;
@ -177,7 +178,7 @@ DGAReInitModes(
int i;
/* No DGA? Ignore call (but don't make it look like it failed) */
if(DGAScreenKey == NULL)
if(!DGAScreenKeyRegistered)
return TRUE;
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
@ -347,7 +348,7 @@ xf86SetDGAMode(
DGAModePtr pMode = NULL;
/* First check if DGAInit was successful on this screen */
if (DGAScreenKey == NULL)
if (!DGAScreenKeyRegistered)
return BadValue;
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
if (!pScreenPriv)
@ -478,7 +479,7 @@ DGAChangePixmapMode(int index, int *x, int *y, int mode)
DGAModePtr pMode;
PixmapPtr pPix;
if(DGAScreenKey == NULL)
if(!DGAScreenKeyRegistered)
return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@ -528,7 +529,7 @@ DGAChangePixmapMode(int index, int *x, int *y, int mode)
Bool
DGAAvailable(int index)
{
if(DGAScreenKey == NULL)
if(!DGAScreenKeyRegistered)
return FALSE;
if(DGA_GET_SCREEN_PRIV(screenInfo.screens[index]))
@ -542,7 +543,7 @@ DGAActive(int index)
{
DGAScreenPtr pScreenPriv;
if(DGAScreenKey == NULL)
if(!DGAScreenKeyRegistered)
return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@ -563,7 +564,7 @@ DGAShutdown(void)
ScrnInfoPtr pScrn;
int i;
if(DGAScreenKey == NULL)
if(!DGAScreenKeyRegistered)
return;
for(i = 0; i < screenInfo.numScreens; i++) {
@ -893,7 +894,7 @@ DGAVTSwitch(void)
/* Alternatively, this could send events to DGA clients */
if(DGAScreenKey) {
if(DGAScreenKeyRegistered) {
DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
if(pScreenPriv && pScreenPriv->current)
@ -910,7 +911,7 @@ DGAStealKeyEvent(DeviceIntPtr dev, int index, int key_code, int is_down)
DGAScreenPtr pScreenPriv;
DGAEvent event;
if(DGAScreenKey == NULL) /* no DGA */
if(!DGAScreenKeyRegistered) /* no DGA */
return FALSE;
if (key_code < 8 || key_code > 255)
@ -943,7 +944,7 @@ DGAStealMotionEvent(DeviceIntPtr dev, int index, int dx, int dy)
DGAScreenPtr pScreenPriv;
DGAEvent event;
if(DGAScreenKey == NULL) /* no DGA */
if(!DGAScreenKeyRegistered) /* no DGA */
return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@ -981,7 +982,7 @@ DGAStealButtonEvent(DeviceIntPtr dev, int index, int button, int is_down)
DGAScreenPtr pScreenPriv;
DGAEvent event;
if (DGAScreenKey == NULL)
if(!DGAScreenKeyRegistered) /* no DGA */
return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@ -1009,7 +1010,7 @@ Bool
DGAIsDgaEvent (xEvent *e)
{
int coreEquiv;
if (DGAScreenKey == NULL || XDGAEventBase == 0)
if (!DGAScreenKeyRegistered || XDGAEventBase == 0)
return FALSE;
coreEquiv = e->u.u.type - *XDGAEventBase;
if (KeyPress <= coreEquiv && coreEquiv <= MotionNotify)
@ -1203,7 +1204,7 @@ DGAHandleEvent(int screen_num, InternalEvent *ev, DeviceIntPtr device)
DGAScreenPtr pScreenPriv;
/* no DGA */
if (DGAScreenKey == NULL || XDGAEventBase == 0)
if (!DGAScreenKeyRegistered || XDGAEventBase == 0)
return;
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);

View File

@ -46,7 +46,7 @@
#ifdef DPMSExtension
static int DPMSKeyIndex;
static DevPrivateKeyRec DPMSKeyRec;
static DevPrivateKey DPMSKey;
static Bool DPMSClose(int i, ScreenPtr pScreen);
static int DPMSCount = 0;
@ -62,10 +62,9 @@ xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags)
pointer DPMSOpt;
MessageType enabled_from;
DPMSKey = &DPMSKeyIndex;
DPMSKey = &DPMSKeyRec;
if (!dixSetPrivate(&pScreen->devPrivates, DPMSKey,
calloc(sizeof(DPMSRec), 1)))
if (!dixRegisterPrivateKey(&DPMSKeyRec, PRIVATE_SCREEN, sizeof (DPMSRec)))
return FALSE;
pDPMS = dixLookupPrivate(&pScreen->devPrivates, DPMSKey);
@ -127,8 +126,6 @@ DPMSClose(int i, ScreenPtr pScreen)
xf86Screens[i]->DPMSSet(xf86Screens[i],DPMSModeOn,0);
}
free(pDPMS);
dixSetPrivate(&pScreen->devPrivates, DPMSKey, NULL);
if (--DPMSCount == 0)
DPMSKey = NULL;
return pScreen->CloseScreen(i, pScreen);

View File

@ -47,14 +47,10 @@
/* Globals that video drivers may access */
/* Index into pScreen.devPrivates */
static int xf86CreateRootWindowKeyIndex;
DevPrivateKey xf86CreateRootWindowKey = &xf86CreateRootWindowKeyIndex;
/* Index of ScrnInfo in pScreen.devPrivates */
static int xf86ScreenKeyIndex;
DevPrivateKey xf86ScreenKey = &xf86ScreenKeyIndex;
static int xf86PixmapKeyIndex;
DevPrivateKey xf86PixmapKey = &xf86PixmapKeyIndex;
DevPrivateKeyRec xf86CreateRootWindowKeyRec;
DevPrivateKeyRec xf86ScreenKeyRec;
DevPrivateKeyRec xf86PixmapKeyRec;
ScrnInfoPtr *xf86Screens = NULL; /* List of ScrnInfos */
const unsigned char byte_reversed[256] =
{

View File

@ -66,6 +66,7 @@
#include "xf86Priv.h"
#include "xf86Config.h"
#include "xf86_OSlib.h"
#include "xf86cmap.h"
#include "xorgVersion.h"
#include "xf86Build.h"
#include "mipointer.h"
@ -734,6 +735,15 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
}
#endif /* SCO325 */
for (i = 0; i < xf86NumScreens; i++)
if (!xf86ColormapAllocatePrivates(xf86Screens[i]))
FatalError("Cannot register DDX private keys");
if (!dixRegisterPrivateKey(&xf86ScreenKeyRec, PRIVATE_SCREEN, 0) ||
!dixRegisterPrivateKey(&xf86CreateRootWindowKeyRec, PRIVATE_SCREEN, 0) ||
!dixRegisterPrivateKey(&xf86PixmapKeyRec, PRIVATE_PIXMAP, 0))
FatalError("Cannot register DDX private keys");
for (i = 0; i < xf86NumScreens; i++) {
xf86VGAarbiterLock(xf86Screens[i]);
/*

View File

@ -46,7 +46,7 @@ typedef struct _xf86RandRInfo {
Rotation rotation;
} XF86RandRInfoRec, *XF86RandRInfoPtr;
static int xf86RandRKeyIndex;
static DevPrivateKeyRec xf86RandRKeyRec;
static DevPrivateKey xf86RandRKey;
#define XF86RANDRINFO(p) ((XF86RandRInfoPtr)dixLookupPrivate(&(p)->devPrivates, xf86RandRKey))
@ -424,7 +424,10 @@ xf86RandRInit (ScreenPtr pScreen)
return TRUE;
#endif
xf86RandRKey = &xf86RandRKeyIndex;
xf86RandRKey = &xf86RandRKeyRec;
if (!dixRegisterPrivateKey(&xf86RandRKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
randrp = malloc(sizeof (XF86RandRInfoRec));
if (!randrp)

View File

@ -62,10 +62,10 @@ static miPointerSpriteFuncRec VGAarbiterSpriteFuncs = {
VGAarbiterDeviceCursorInitialize, VGAarbiterDeviceCursorCleanup
};
static int VGAarbiterKeyIndex;
static DevPrivateKey VGAarbiterScreenKey = &VGAarbiterKeyIndex;
static int VGAarbiterGCIndex;
static DevPrivateKey VGAarbiterGCKey = &VGAarbiterGCIndex;
static DevPrivateKeyRec VGAarbiterScreenKeyRec;
#define VGAarbiterScreenKey (&VGAarbiterScreenKeyRec)
static DevPrivateKeyRec VGAarbiterGCKeyRec;
#define VGAarbiterGCKey (&VGAarbiterGCKeyRec)
static int vga_no_arb = 0;
void
@ -175,9 +175,12 @@ xf86VGAarbiterWrapFunctions(void)
pScrn = xf86Screens[pScreen->myNum];
PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
if (!dixRequestPrivate(VGAarbiterGCKey, sizeof(VGAarbiterGCRec)))
if (!dixRegisterPrivateKey(&VGAarbiterGCKeyRec, PRIVATE_GC, sizeof(VGAarbiterGCRec)))
return FALSE;
if (!dixRegisterPrivateKey(&VGAarbiterScreenKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if (!(pScreenPriv = malloc(sizeof(VGAarbiterScreenRec))))
return FALSE;

View File

@ -47,7 +47,7 @@
#include "vidmodeproc.h"
#include "xf86cmap.h"
static int VidModeKeyIndex;
static DevPrivateKeyRec VidModeKeyRec;
static DevPrivateKey VidModeKey;
static int VidModeCount = 0;
static Bool VidModeClose(int i, ScreenPtr pScreen);
@ -67,15 +67,17 @@ VidModeExtensionInit(ScreenPtr pScreen)
return FALSE;
}
VidModeKey = &VidModeKeyIndex;
VidModeKey = &VidModeKeyRec;
if (!dixSetPrivate(&pScreen->devPrivates, VidModeKey,
calloc(sizeof(VidModeRec), 1))) {
DebugF("xcalloc failed\n");
if (!dixRegisterPrivateKey(&VidModeKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
}
pVidMode = VMPTR(pScreen);
pVidMode = calloc(sizeof(VidModeRec), 1);
if (!pVidMode)
return FALSE;
dixSetPrivate(&pScreen->devPrivates, VidModeKey, pVidMode);
pVidMode->Flags = 0;
pVidMode->Next = NULL;
pVidMode->CloseScreen = pScreen->CloseScreen;

View File

@ -102,10 +102,11 @@ typedef struct {
int overscan;
} CMapColormapRec, *CMapColormapPtr;
static int CMapScreenKeyIndex;
static DevPrivateKey CMapScreenKey;
static int CMapColormapKeyIndex;
static DevPrivateKey CMapColormapKey = &CMapColormapKeyIndex;
static DevPrivateKeyRec CMapScreenKeyRec;
#define CMapScreenKeyRegistered dixPrivateKeyRegistered(&CMapScreenKeyRec)
#define CMapScreenKey (&CMapScreenKeyRec)
static DevPrivateKeyRec CMapColormapKeyRec;
#define CMapColormapKey (&CMapColormapKeyRec)
static void CMapInstallColormap(ColormapPtr);
static void CMapStoreColors(ColormapPtr, int, xColorItem *);
@ -128,6 +129,18 @@ static void CMapReinstallMap(ColormapPtr);
static void CMapUnwrapScreen(ScreenPtr pScreen);
Bool xf86ColormapAllocatePrivates(ScrnInfoPtr pScrn)
{
/* If we support a better colormap system, then pretend we succeeded. */
if (xf86_crtc_supports_gamma(pScrn))
return TRUE;
if (!dixRegisterPrivateKey(&CMapScreenKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if (!dixRegisterPrivateKey(&CMapColormapKeyRec, PRIVATE_COLORMAP, 0))
return FALSE;
return TRUE;
}
Bool xf86HandleColormaps(
ScreenPtr pScreen,
@ -151,8 +164,6 @@ Bool xf86HandleColormaps(
if(!maxColors || !sigRGBbits || !loadPalette)
return FALSE;
CMapScreenKey = &CMapScreenKeyIndex;
elements = 1 << sigRGBbits;
if(!(gamma = malloc(elements * sizeof(LOCO))))
@ -169,7 +180,7 @@ Bool xf86HandleColormaps(
return FALSE;
}
dixSetPrivate(&pScreen->devPrivates, CMapScreenKey, pScreenPriv);
dixSetPrivate(&pScreen->devPrivates, &CMapScreenKeyRec, pScreenPriv);
pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreenPriv->CreateColormap = pScreen->CreateColormap;
@ -900,7 +911,7 @@ CMapChangeGamma(
CMapLinkPtr pLink;
/* Is this sufficient checking ? */
if(CMapScreenKey == NULL)
if(!CMapScreenKeyRegistered)
return BadImplementation;
pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
@ -1012,7 +1023,7 @@ xf86ChangeGammaRamp(
}
}
if(CMapScreenKey == NULL)
if(!CMapScreenKeyRegistered)
return BadImplementation;
pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
@ -1080,7 +1091,7 @@ xf86GetGammaRampSize(ScreenPtr pScreen)
return crtc->gammaSize;
}
if(CMapScreenKey == NULL) return 0;
if(!CMapScreenKeyRegistered) return 0;
pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
CMapScreenKey);
@ -1120,7 +1131,7 @@ xf86GetGammaRamp(
}
}
if(CMapScreenKey == NULL)
if(!CMapScreenKeyRegistered)
return BadImplementation;
pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,

View File

@ -45,6 +45,10 @@ extern _X_EXPORT Bool xf86HandleColormaps(
unsigned int flags
);
extern _X_EXPORT Bool xf86ColormapAllocatePrivates(
ScrnInfoPtr pScrn
);
extern _X_EXPORT int
xf86ChangeGamma(
ScreenPtr pScreen,

View File

@ -42,7 +42,7 @@
#define DEBUG
*/
static int xf86FBManagerKeyIndex;
static DevPrivateKeyRec xf86FBManagerKeyRec;
static DevPrivateKey xf86FBManagerKey;
Bool xf86RegisterOffscreenManager(
@ -50,7 +50,11 @@ Bool xf86RegisterOffscreenManager(
FBManagerFuncsPtr funcs
){
xf86FBManagerKey = &xf86FBManagerKeyIndex;
xf86FBManagerKey = &xf86FBManagerKeyRec;
if (!dixRegisterPrivateKey(&xf86FBManagerKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
dixSetPrivate(&pScreen->devPrivates, xf86FBManagerKey, funcs);
return TRUE;
@ -60,8 +64,9 @@ Bool xf86RegisterOffscreenManager(
Bool
xf86FBManagerRunning(ScreenPtr pScreen)
{
if(xf86FBManagerKey == NULL)
if (xf86FBManagerKey == NULL)
return FALSE;
if(!dixLookupPrivate(&pScreen->devPrivates, xf86FBManagerKey))
return FALSE;
@ -270,8 +275,8 @@ xf86PurgeUnlockedOffscreenAreas(ScreenPtr pScreen)
\************************************************************/
static int xf86FBScreenKeyIndex;
static DevPrivateKey xf86FBScreenKey = &xf86FBScreenKeyIndex;
static DevPrivateKeyRec xf86FBScreenKeyRec;
#define xf86FBScreenKey (&xf86FBScreenKeyRec)
typedef struct _FBLink {
FBArea area;
@ -1321,6 +1326,9 @@ xf86InitFBManagerRegion(
if(RegionNil(FullRegion))
return FALSE;
if (!dixRegisterPrivateKey(&xf86FBScreenKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if(!xf86RegisterOffscreenManager(pScreen, &xf86FBManFuncs))
return FALSE;

View File

@ -110,10 +110,11 @@ static void xf86XVAdjustFrame(int index, int x, int y, int flags);
static Bool xf86XVInitAdaptors(ScreenPtr, XF86VideoAdaptorPtr*, int);
static int XF86XVWindowKeyIndex;
static DevPrivateKey XF86XVWindowKey = &XF86XVWindowKeyIndex;
static int XF86XvScreenKeyIndex;
DevPrivateKey XF86XvScreenKey = &XF86XvScreenKeyIndex;
static DevPrivateKeyRec XF86XVWindowKeyRec;
#define XF86XVWindowKey (&XF86XVWindowKeyRec)
DevPrivateKey XF86XvScreenKey;
static unsigned long PortResource = 0;
DevPrivateKey (*XvGetScreenKeyProc)(void) = NULL;
@ -186,8 +187,8 @@ typedef struct {
int num;
} OffscreenImageRec;
static int OffscreenPrivateKeyIndex;
static DevPrivateKey OffscreenPrivateKey = &OffscreenPrivateKeyIndex;
static DevPrivateKeyRec OffscreenPrivateKeyRec;
#define OffscreenPrivateKey (&OffscreenPrivateKeyRec)
#define GetOffscreenImage(pScreen) ((OffscreenImageRec *) dixLookupPrivate(&(pScreen)->devPrivates, OffscreenPrivateKey))
Bool
@ -198,9 +199,9 @@ xf86XVRegisterOffscreenImages(
){
OffscreenImageRec *OffscreenImage;
/* This function may be called before xf86XVScreenInit, so there's
* no better place than this to call dixRequestPrivate to ensure we
* no better place than this to call dixRegisterPrivateKey to ensure we
* have space reserved. After the first call it is a no-op. */
if(!dixRequestPrivate(OffscreenPrivateKey, sizeof(OffscreenImageRec)) ||
if(!dixRegisterPrivateKey(OffscreenPrivateKey, PRIVATE_SCREEN, sizeof(OffscreenImageRec)) ||
!(OffscreenImage = GetOffscreenImage(pScreen)))
/* Every X.org driver assumes this function always succeeds, so
* just die on allocation failure. */
@ -251,7 +252,11 @@ xf86XVScreenInit(
if(Success != (*XvScreenInitProc)(pScreen)) return FALSE;
if (!dixRegisterPrivateKey(&XF86XVWindowKeyRec, PRIVATE_WINDOW, 0))
return FALSE;
XF86XvScreenKey = (*XvGetScreenKeyProc)();
PortResource = (*XvGetRTPortProc)();
pxvs = GET_XV_SCREEN(pScreen);

View File

@ -55,8 +55,8 @@ typedef struct {
XvMCAdaptorPtr dixinfo;
} xf86XvMCScreenRec, *xf86XvMCScreenPtr;
static int XF86XvMCScreenKeyIndex;
static DevPrivateKey XF86XvMCScreenKey = &XF86XvMCScreenKeyIndex;
static DevPrivateKeyRec XF86XvMCScreenKeyRec;
#define XF86XvMCScreenKey (&XF86XvMCScreenKeyRec)
#define XF86XVMC_GET_PRIVATE(pScreen) (xf86XvMCScreenPtr) \
dixLookupPrivate(&(pScreen)->devPrivates, XF86XvMCScreenKey)
@ -172,6 +172,9 @@ Bool xf86XvMCScreenInit(
if(!(pAdapt = malloc(sizeof(XvMCAdaptorRec) * num_adaptors)))
return FALSE;
if (!dixRegisterPrivateKey(&XF86XvMCScreenKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if(!(pScreenPriv = malloc(sizeof(xf86XvMCScreenRec)))) {
free(pAdapt);
return FALSE;

View File

@ -61,10 +61,11 @@ unsigned char DGAReqCode = 0;
int DGAErrorBase;
int DGAEventBase;
static int DGAScreenPrivateKeyIndex;
static DevPrivateKey DGAScreenPrivateKey = &DGAScreenPrivateKeyIndex;
static int DGAClientPrivateKeyIndex;
static DevPrivateKey DGAClientPrivateKey = &DGAClientPrivateKeyIndex;
static DevPrivateKeyRec DGAScreenPrivateKeyRec;
#define DGAScreenPrivateKey (&DGAScreenPrivateKeyRec)
#define DGAScreenPrivateKeyRegistered (DGAScreenPrivateKeyRec.initialized)
static DevPrivateKeyRec DGAClientPrivateKeyRec;
#define DGAClientPrivateKey (&DGAClientPrivateKeyRec)
static int DGACallbackRefCount = 0;
/* This holds the client's version information */
@ -89,6 +90,12 @@ XFree86DGAExtensionInit(INITARGS)
{
ExtensionEntry* extEntry;
if (!dixRegisterPrivateKey(&DGAClientPrivateKeyRec, PRIVATE_CLIENT, 0))
return;
if (!dixRegisterPrivateKey(&DGAScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
return;
if ((extEntry = AddExtension(XF86DGANAME,
XF86DGANumberEvents,
XF86DGANumberErrors,
@ -717,13 +724,13 @@ ProcXF86DGADirectVideo(ClientPtr client)
if (stuff->screen > screenInfo.numScreens)
return BadValue;
owner = DGA_GETCLIENT(stuff->screen);
REQUEST_SIZE_MATCH(xXF86DGADirectVideoReq);
if (!DGAAvailable(stuff->screen))
return DGAErrorBase + XF86DGANoDirectVideoMode;
owner = DGA_GETCLIENT(stuff->screen);
if (owner && owner != client)
return DGAErrorBase + XF86DGANoDirectVideoMode;

View File

@ -51,8 +51,8 @@ from Kaleb S. KEITHLEY
#define DEFAULT_XF86VIDMODE_VERBOSITY 3
static int VidModeErrorBase;
static int VidModeClientPrivateKeyIndex;
static DevPrivateKey VidModeClientPrivateKey = &VidModeClientPrivateKeyIndex;
static DevPrivateKeyRec VidModeClientPrivateKeyRec;
#define VidModeClientPrivateKey (&VidModeClientPrivateKeyRec)
/* This holds the client's version information */
typedef struct {
@ -141,8 +141,8 @@ typedef struct _XF86VidModeScreenPrivate {
Bool hasWindow;
} XF86VidModeScreenPrivateRec, *XF86VidModeScreenPrivatePtr;
static int ScreenPrivateKeyIndex;
static DevPrivateKey ScreenPrivateKey = &ScreenPrivateKeyIndex;
static DevPrivateKeyRec ScreenPrivateKeyRec;
#define ScreenPrivateKey (&ScreenPrivateKeyRec)
#define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr) \
dixLookupPrivate(&(s)->devPrivates, ScreenPrivateKey))
@ -169,6 +169,13 @@ XFree86VidModeExtensionInit(void)
DEBUG_P("XFree86VidModeExtensionInit");
if (!dixRegisterPrivateKey(&VidModeClientPrivateKeyRec, PRIVATE_CLIENT, 0))
return;
#ifdef XF86VIDMODE_EVENTS
if (!dixRegisterPrivateKey(&ScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
return;
#endif
#ifdef XF86VIDMODE_EVENTS
EventType = CreateNewResourceType(XF86VidModeFreeEvents, "VidModeEvent");
#endif
@ -177,9 +184,6 @@ XFree86VidModeExtensionInit(void)
pScreen = screenInfo.screens[i];
if (VidModeExtensionInit(pScreen))
enabled = TRUE;
#ifdef XF86VIDMODE_EVENTS
SetScreenPrivate (pScreen, NULL);
#endif
}
/* This means that the DDX doesn't want the vidmode extension enabled */
if (!enabled)

View File

@ -74,10 +74,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define PCI_BUS_NO_DOMAIN(bus) ((bus) & 0xffu)
static int DRIEntPrivIndex = -1;
static int DRIScreenPrivKeyIndex;
static DevPrivateKey DRIScreenPrivKey = &DRIScreenPrivKeyIndex;
static int DRIWindowPrivKeyIndex;
static DevPrivateKey DRIWindowPrivKey = &DRIWindowPrivKeyIndex;
static DevPrivateKeyRec DRIScreenPrivKeyRec;
#define DRIScreenPrivKey (&DRIScreenPrivKeyRec)
static DevPrivateKeyRec DRIWindowPrivKeyRec;
#define DRIWindowPrivKey (&DRIWindowPrivKeyRec)
static unsigned long DRIGeneration = 0;
static unsigned int DRIDrawableValidationStamp = 0;
@ -357,6 +357,11 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
if (DRIGeneration != serverGeneration)
DRIGeneration = serverGeneration;
if (!dixRegisterPrivateKey(&DRIScreenPrivKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if (!dixRegisterPrivateKey(&DRIWindowPrivKeyRec, PRIVATE_WINDOW, 0))
return FALSE;
pDRIPriv = (DRIScreenPrivPtr) calloc(1, sizeof(DRIScreenPrivRec));
if (!pDRIPriv) {
dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
@ -785,7 +790,7 @@ drmServerInfo DRIDRMServerInfo = {
Bool
DRIExtensionInit(void)
{
if (!DRIScreenPrivKey || DRIGeneration != serverGeneration) {
if (DRIGeneration != serverGeneration) {
return FALSE;
}

View File

@ -51,12 +51,15 @@
CARD8 dri2_major; /* version of DRI2 supported by DDX */
CARD8 dri2_minor;
static int dri2ScreenPrivateKeyIndex;
static DevPrivateKey dri2ScreenPrivateKey = &dri2ScreenPrivateKeyIndex;
static int dri2WindowPrivateKeyIndex;
static DevPrivateKey dri2WindowPrivateKey = &dri2WindowPrivateKeyIndex;
static int dri2PixmapPrivateKeyIndex;
static DevPrivateKey dri2PixmapPrivateKey = &dri2PixmapPrivateKeyIndex;
static DevPrivateKeyRec dri2ScreenPrivateKeyRec;
#define dri2ScreenPrivateKey (&dri2ScreenPrivateKeyRec)
static DevPrivateKeyRec dri2WindowPrivateKeyRec;
#define dri2WindowPrivateKey (&dri2WindowPrivateKeyRec)
static DevPrivateKeyRec dri2PixmapPrivateKeyRec;
#define dri2PixmapPrivateKey (&dri2PixmapPrivateKeyRec)
static RESTYPE dri2DrawableRes;
typedef struct _DRI2Screen *DRI2ScreenPtr;
@ -1025,6 +1028,15 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
return FALSE;
}
if (!dixRegisterPrivateKey(&dri2ScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if (!dixRegisterPrivateKey(&dri2WindowPrivateKeyRec, PRIVATE_WINDOW, 0))
return FALSE;
if (!dixRegisterPrivateKey(&dri2PixmapPrivateKeyRec, PRIVATE_PIXMAP, 0))
return FALSE;
ds = calloc(1, sizeof *ds);
if (!ds)
return FALSE;

View File

@ -42,8 +42,8 @@ typedef struct _ExaXorgScreenPrivRec {
OptionInfoPtr options;
} ExaXorgScreenPrivRec, *ExaXorgScreenPrivPtr;
static int exaXorgScreenPrivateKeyIndex;
static DevPrivateKey exaXorgScreenPrivateKey = &exaXorgScreenPrivateKeyIndex;
static DevPrivateKeyRec exaXorgScreenPrivateKeyRec;
#define exaXorgScreenPrivateKey (&exaXorgScreenPrivateKeyRec)
typedef enum {
EXAOPT_MIGRATION_HEURISTIC,
@ -114,6 +114,9 @@ exaDDXDriverInit(ScreenPtr pScreen)
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
ExaXorgScreenPrivPtr pScreenPriv;
if (!dixRegisterPrivateKey(&exaXorgScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
return;
pScreenPriv = calloc(1, sizeof(ExaXorgScreenPrivRec));
if (pScreenPriv == NULL)
return;

View File

@ -71,7 +71,7 @@ static Bool xf86RandR12CreateScreenResources12 (ScreenPtr pScreen);
static int xf86RandR12Generation;
#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0)
static int xf86RandR12KeyIndex;
static DevPrivateKeyRec xf86RandR12KeyRec;
static DevPrivateKey xf86RandR12Key;
#define XF86RANDRINFO(p) ((XF86RandRInfoPtr) \
dixLookupPrivate(&(p)->devPrivates, xf86RandR12Key))
@ -883,7 +883,9 @@ xf86RandR12Init (ScreenPtr pScreen)
xf86RandR12Generation = serverGeneration;
#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0)
xf86RandR12Key = &xf86RandR12KeyIndex;
xf86RandR12Key = &xf86RandR12KeyRec;
if (!dixRegisterPrivateKey(&xf86RandR12KeyRec, PRIVATE_SCREEN, 0))
return FALSE;
#else
xf86RandR12Index = AllocateScreenPrivateIndex();
#endif

View File

@ -18,8 +18,7 @@
#include "inputstr.h"
extern InputInfo inputInfo;
static int xf86CursorScreenKeyIndex;
DevPrivateKey xf86CursorScreenKey = &xf86CursorScreenKeyIndex;
DevPrivateKeyRec xf86CursorScreenKeyRec;
/* sprite functions */
@ -65,6 +64,9 @@ xf86InitCursor(
if (!xf86InitHardwareCursor(pScreen, infoPtr))
return FALSE;
if (!dixRegisterPrivateKey(&xf86CursorScreenKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
ScreenPriv = calloc(1, sizeof(xf86CursorScreenRec));
if (!ScreenPriv)
return FALSE;

View File

@ -45,6 +45,7 @@ Bool xf86InitHardwareCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr);
CARD32 xf86ReverseBitOrder(CARD32 data);
extern _X_EXPORT DevPrivateKey xf86CursorScreenKey;
extern _X_EXPORT DevPrivateKeyRec xf86CursorScreenKeyRec;
#define xf86CursorScreenKey (&xf86CursorScreenKeyRec)
#endif /* _XF86CURSORPRIV_H */

View File

@ -84,11 +84,11 @@ typedef struct {
GCFuncs *funcs;
} ShadowGCRec, *ShadowGCPtr;
static DevPrivateKeyRec ShadowScreenKeyRec;
#define ShadowScreenKey (&ShadowScreenKeyRec)
static int ShadowScreenKeyIndex;
static DevPrivateKey ShadowScreenKey = &ShadowScreenKeyIndex;
static int ShadowGCKeyIndex;
static DevPrivateKey ShadowGCKey = &ShadowGCKeyIndex;
static DevPrivateKeyRec ShadowGCKeyRec;
#define ShadowGCKey (&ShadowGCKeyRec)
#define GET_SCREEN_PRIVATE(pScreen) \
(ShadowScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, ShadowScreenKey)
@ -162,7 +162,10 @@ ShadowFBInit2 (
if(!preRefreshArea && !postRefreshArea) return FALSE;
if(!dixRequestPrivate(ShadowGCKey, sizeof(ShadowGCRec)))
if (!dixRegisterPrivateKey(&ShadowScreenKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if(!dixRegisterPrivateKey(&ShadowGCKeyRec, PRIVATE_GC, sizeof(ShadowGCRec)))
return FALSE;
if(!(pPriv = (ShadowScreenPtr)malloc(sizeof(ShadowScreenRec))))

View File

@ -42,12 +42,12 @@ static int XAASetDGAMode(int index, int num, DGADevicePtr devRet);
static void XAAEnableDisableFBAccess (int index, Bool enable);
static Bool XAAChangeWindowAttributes (WindowPtr pWin, unsigned long mask);
static int XAAScreenKeyIndex;
static DevPrivateKey XAAScreenKey = &XAAScreenKeyIndex;
static int XAAGCKeyIndex;
static DevPrivateKey XAAGCKey = &XAAGCKeyIndex;
static int XAAPixmapKeyIndex;
static DevPrivateKey XAAPixmapKey = &XAAPixmapKeyIndex;
static DevPrivateKeyRec XAAScreenKeyRec;
#define XAAScreenKey (&XAAScreenKeyRec)
static DevPrivateKeyRec XAAGCKeyRec;
#define XAAGCKey (&XAAGCKeyRec)
static DevPrivateKeyRec XAAPixmapKeyRec;
#define XAAPixmapKey (&XAAPixmapKeyRec)
DevPrivateKey XAAGetScreenKey(void) {
return XAAScreenKey;
@ -106,10 +106,13 @@ XAAInit(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
if (!infoRec)
return TRUE;
if (!dixRequestPrivate(XAAGCKey, sizeof(XAAGCRec)))
if (!dixRegisterPrivateKey(&XAAGCKeyRec, PRIVATE_GC, sizeof(XAAGCRec)))
return FALSE;
if (!dixRequestPrivate(XAAPixmapKey, sizeof(XAAPixmapRec)))
if (!dixRegisterPrivateKey(&XAAPixmapKeyRec, PRIVATE_PIXMAP, sizeof(XAAPixmapRec)))
return FALSE;
if (!dixRegisterPrivateKey(&XAAScreenKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if (!(pScreenPriv = malloc(sizeof(XAAScreenRec))))

View File

@ -151,8 +151,8 @@ typedef struct {
int (*TiledFillChooser)(GCPtr);
} XAAOverlayRec, *XAAOverlayPtr;
static int XAAOverlayKeyIndex;
static DevPrivateKey XAAOverlayKey = &XAAOverlayKeyIndex;
static DevPrivateKeyRec XAAOverlayKeyRec;
#define XAAOverlayKey (&XAAOverlayKeyRec)
#define GET_OVERLAY_PRIV(pScreen) \
(XAAOverlayPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAOverlayKey)
@ -173,6 +173,9 @@ XAAInitDualFramebufferOverlay(
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
XAAOverlayPtr pOverPriv;
if (!dixRegisterPrivateKey(&XAAOverlayKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if(!(pOverPriv = malloc(sizeof(XAAOverlayRec))))
return FALSE;

View File

@ -272,8 +272,8 @@ typedef struct _XAAStateWrapRec {
int width, int height, int flags);
} XAAStateWrapRec, *XAAStateWrapPtr;
static int XAAStateKeyIndex;
static DevPrivateKey XAAStateKey = &XAAStateKeyIndex;
static DevPrivateKeyRec XAAStateKeyRec;
#define XAAStateKey (&XAAStateKeyRec)
/* Wrap functions start here */
#define GET_STATEPRIV_GC(pGC) XAAStateWrapPtr pStatePriv =\
@ -1500,6 +1500,7 @@ XAAInitStateWrap(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
XAAStateWrapPtr pStatePriv;
int i = 0;
if (!dixRegisterPrivateKey(&XAAStateKeyRec, PRIVATE_SCREEN, 0)) return FALSE;
if(!(pStatePriv = malloc(sizeof(XAAStateWrapRec)))) return FALSE;
dixSetPrivate(&pScreen->devPrivates, XAAStateKey, pStatePriv);
pStatePriv->RestoreAccelState = infoRec->RestoreAccelState;

View File

@ -125,10 +125,10 @@ typedef struct _xaaWrapperGCPriv {
#define xaaWrapperGCPriv(pGC) xaaWrapperGCPrivPtr pGCPriv = xaaWrapperGetGCPriv(pGC)
static int xaaWrapperScrPrivateKeyIndex;
static DevPrivateKey xaaWrapperScrPrivateKey = &xaaWrapperScrPrivateKeyIndex;
static int xaaWrapperGCPrivateKeyIndex;
static DevPrivateKey xaaWrapperGCPrivateKey = &xaaWrapperGCPrivateKeyIndex;
static DevPrivateKeyRec xaaWrapperScrPrivateKeyRec;
#define xaaWrapperScrPrivateKey (&xaaWrapperScrPrivateKeyRec)
static DevPrivateKeyRec xaaWrapperGCPrivateKeyRec;
#define xaaWrapperGCPrivateKey (&xaaWrapperGCPrivateKeyRec)
static Bool
xaaWrapperCreateScreenResources(ScreenPtr pScreen)
@ -268,7 +268,10 @@ xaaSetupWrapper(ScreenPtr pScreen, XAAInfoRecPtr infoPtr, int depth, SyncFunc *f
xaaWrapperScrPrivPtr pScrPriv;
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
if (!dixRequestPrivate(xaaWrapperGCPrivateKey, sizeof(xaaWrapperGCPrivRec)))
if (!dixRegisterPrivateKey(&xaaWrapperGCPrivateKeyRec, PRIVATE_GC, sizeof(xaaWrapperGCPrivRec)))
return FALSE;
if (!dixRegisterPrivateKey(&xaaWrapperScrPrivateKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
pScrPriv = (xaaWrapperScrPrivPtr) malloc(sizeof (xaaWrapperScrPrivRec));

View File

@ -34,8 +34,8 @@ is" without express or implied warranty.
#include "XNWindow.h"
#include "Args.h"
static int cmapScrPrivateKeyIndex;
static DevPrivateKey cmapScrPrivateKey = &cmapScrPrivateKeyIndex;
static DevPrivateKeyRec cmapScrPrivateKeyRec;
#define cmapScrPrivateKey (&cmapScrPrivateKeyRec)
#define GetInstalledColormap(s) ((ColormapPtr) dixLookupPrivate(&(s)->devPrivates, cmapScrPrivateKey))
#define SetInstalledColormap(s,c) (dixSetPrivate(&(s)->devPrivates, cmapScrPrivateKey, c))

View File

@ -35,8 +35,7 @@ is" without express or implied warranty.
#include "XNFont.h"
#include "Color.h"
static int xnestGCPrivateKeyIndex;
DevPrivateKey xnestGCPrivateKey = &xnestGCPrivateKeyIndex;
DevPrivateKeyRec xnestGCPrivateKeyRec;
static GCFuncs xnestFuncs = {
xnestValidateGC,

View File

@ -33,8 +33,7 @@ is" without express or implied warranty.
#include "Screen.h"
#include "XNPixmap.h"
static int xnestPixmapPrivateKeyIndex;
DevPrivateKey xnestPixmapPrivateKey = &xnestPixmapPrivateKeyIndex;
DevPrivateKeyRec xnestPixmapPrivateKeyRec;
PixmapPtr
xnestCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
@ -42,7 +41,7 @@ xnestCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
{
PixmapPtr pPixmap;
pPixmap = AllocatePixmap(pScreen, sizeof(xnestPrivPixmap));
pPixmap = AllocatePixmap(pScreen, 0);
if (!pPixmap)
return NullPixmap;
pPixmap->drawable.type = DRAWABLE_PIXMAP;
@ -59,8 +58,6 @@ xnestCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
pPixmap->refcnt = 1;
pPixmap->devKind = PixmapBytePad(width, depth);
pPixmap->usage_hint = usage_hint;
dixSetPrivate(&pPixmap->devPrivates, xnestPixmapPrivateKey,
(char *)pPixmap + pScreen->totalPixmapSize);
if (width && height)
xnestPixmapPriv(pPixmap)->pixmap =
XCreatePixmap(xnestDisplay,
@ -78,8 +75,7 @@ xnestDestroyPixmap(PixmapPtr pPixmap)
if(--pPixmap->refcnt)
return TRUE;
XFreePixmap(xnestDisplay, xnestPixmap(pPixmap));
dixFreePrivates(pPixmap->devPrivates);
free(pPixmap);
FreePixmap(pPixmap);
return TRUE;
}

View File

@ -45,8 +45,7 @@ is" without express or implied warranty.
Window xnestDefaultWindows[MAXSCREENS];
Window xnestScreenSaverWindows[MAXSCREENS];
static int xnestCursorScreenKeyIndex;
DevPrivateKey xnestCursorScreenKey = &xnestCursorScreenKeyIndex;
DevPrivateKeyRec xnestCursorScreenKeyRec;
ScreenPtr
xnestScreen(Window window)
@ -146,10 +145,14 @@ xnestOpenScreen(int index, ScreenPtr pScreen, int argc, char *argv[])
int rootDepth;
miPointerScreenPtr PointPriv;
if (!dixRequestPrivate(xnestWindowPrivateKey, sizeof(xnestPrivWin)))
return False;
if (!dixRequestPrivate(xnestGCPrivateKey, sizeof(xnestPrivGC)))
return False;
if (!dixRegisterPrivateKey(&xnestWindowPrivateKeyRec, PRIVATE_WINDOW, sizeof(xnestPrivWin)))
return FALSE;
if (!dixRegisterPrivateKey(&xnestGCPrivateKeyRec, PRIVATE_GC, sizeof(xnestPrivGC)))
return FALSE;
if (!dixRegisterPrivateKey(&xnestPixmapPrivateKeyRec, PRIVATE_PIXMAP, sizeof (xnestPrivPixmap)))
return FALSE;
if (!dixRegisterPrivateKey(&xnestCursorScreenKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
visuals = (VisualPtr)malloc(xnestNumVisuals * sizeof(VisualRec));
numVisuals = 0;

View File

@ -39,8 +39,7 @@ is" without express or implied warranty.
#include "Events.h"
#include "Args.h"
static int xnestWindowPrivateKeyIndex;
DevPrivateKey xnestWindowPrivateKey = &xnestWindowPrivateKeyIndex;
DevPrivateKeyRec xnestWindowPrivateKeyRec;
static int
xnestFindWindowMatch(WindowPtr pWin, pointer ptr)

View File

@ -21,7 +21,8 @@ typedef struct {
miPointerSpriteFuncPtr spriteFuncs;
} xnestCursorFuncRec, *xnestCursorFuncPtr;
extern DevPrivateKey xnestCursorScreenKey;
extern DevPrivateKeyRec xnestCursorScreenKeyRec;
#define xnestCursorScreenKey (&xnestCursorScreenKeyRec)
extern xnestCursorFuncRec xnestCursorFuncs;
typedef struct {

View File

@ -22,7 +22,8 @@ typedef struct {
int nClipRects;
} xnestPrivGC;
extern DevPrivateKey xnestGCPrivateKey;
extern DevPrivateKeyRec xnestGCPrivateKeyRec;
#define xnestGCPrivateKey (&xnestGCPrivateKeyRec)
#define xnestGCPriv(pGC) ((xnestPrivGC *) \
dixLookupPrivate(&(pGC)->devPrivates, xnestGCPrivateKey))

View File

@ -15,7 +15,8 @@ is" without express or implied warranty.
#ifndef XNESTPIXMAP_H
#define XNESTPIXMAP_H
extern DevPrivateKey xnestPixmapPrivateKey;
extern DevPrivateKeyRec xnestPixmapPrivateKeyRec;
#define xnestPixmapPrivateKey (&xnestPixmapPrivateKeyRec)
typedef struct {
Pixmap pixmap;

View File

@ -33,7 +33,8 @@ typedef struct {
Window window;
} xnestWindowMatch;
extern DevPrivateKey xnestWindowPrivateKey;
extern DevPrivateKeyRec xnestWindowPrivateKeyRec;
#define xnestWindowPrivateKey (&xnestWindowPrivateKeyRec)
#define xnestWindowPriv(pWin) ((xnestPrivWin *) \
dixLookupPrivate(&(pWin)->devPrivates, xnestWindowPrivateKey))

View File

@ -84,8 +84,7 @@ FILE *debug_log_fp = NULL;
* X server shared global variables
*/
int darwinScreensFound = 0;
static int darwinScreenKeyIndex;
DevPrivateKey darwinScreenKey = &darwinScreenKeyIndex;
DevPrivateKeyRec darwinScreenKeyRec;
io_connect_t darwinParamConnect = 0;
int darwinEventReadFD = -1;
int darwinEventWriteFD = -1;
@ -185,6 +184,9 @@ static Bool DarwinScreenInit(int index, ScreenPtr pScreen, int argc, char **argv
Bool ret;
DarwinFramebufferPtr dfb;
if (!dixRegisterPrivateKey(&darwinScreenKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
// reset index of found screens for each server generation
if (index == 0) {
foundIndex = 0;

View File

@ -50,7 +50,8 @@ void xf86SetRootClip (ScreenPtr pScreen, int enable);
/*
* Global variables from darwin.c
*/
extern DevPrivateKey darwinScreenKey; // index into pScreen.devPrivates
extern DevPrivateKeyRec darwinScreenKeyRec;
#define darwinScreenKey (&darwinScreenKeyRec)
extern int darwinScreensFound;
extern io_connect_t darwinParamConnect;
extern int darwinEventReadFD;

View File

@ -73,8 +73,7 @@ int quartzUseAGL = 1;
int quartzEnableKeyEquivalents = 1;
int quartzServerVisible = FALSE;
int quartzServerQuitting = FALSE;
static int quartzScreenKeyIndex;
DevPrivateKey quartzScreenKey = &quartzScreenKeyIndex;
DevPrivateKeyRec quartzScreenKeyRec;
int aquaMenuBarHeight = 0;
QuartzModeProcsPtr quartzProcs = NULL;
const char *quartzOpenGLBundle = NULL;
@ -167,6 +166,9 @@ void QuartzInitOutput(
FatalError("Could not register block and wakeup handlers.");
}
if (!dixRegisterPrivateKey(&quartzScreenKeyRec, PRIVATE_SCREEN, 0))
FatalError("Failed to alloc quartz screen private.\n");
#if defined(RANDR) && !defined(FAKE_RANDR)
if(!QuartzRandRInit(pScreen))
FatalError("Failed to init RandR extension.\n");

View File

@ -65,7 +65,8 @@ extern int quartzOptionSendsAlt;
// Other shared data
extern int quartzServerVisible;
extern int quartzServerQuitting;
extern DevPrivateKey quartzScreenKey;
extern DevPrivateKeyRec quartzScreenKeyRec;
#define quartzScreenKey (&quartzScreenKeyRec)
extern int aquaMenuBarHeight;
// Name of GLX bundle for native OpenGL

Some files were not shown because too many files have changed in this diff Show More