diff --git a/dbe/dbe.c b/dbe/dbe.c index fba10d689..9b5474c81 100644 --- a/dbe/dbe.c +++ b/dbe/dbe.c @@ -1576,10 +1576,6 @@ DbeExtensionInit(void) if (!dbeWindowPrivResType) return; - if (!dixRegisterPrivateOffset(dbeDrawableResType, - offsetof(PixmapRec, devPrivates))) - return; - for (i = 0; i < screenInfo.numScreens; i++) { /* For each screen, set up DBE screen privates and init DIX and DDX diff --git a/dix/privates.c b/dix/privates.c index 4a8a186dc..9ec6c46be 100644 --- a/dix/privates.c +++ b/dix/privates.c @@ -208,7 +208,7 @@ dixFreePrivates(PrivateRec *privates) } /* Table of devPrivates offsets */ -static const int offsetDefaults[] = { +static const int offsets[] = { -1, /* RT_NONE */ offsetof(WindowRec, devPrivates), /* RT_WINDOW */ offsetof(PixmapRec, devPrivates), /* RT_PIXMAP */ @@ -216,45 +216,27 @@ static const int offsetDefaults[] = { -1, /* RT_FONT */ offsetof(CursorRec, devPrivates), /* RT_CURSOR */ offsetof(ColormapRec, devPrivates), /* RT_COLORMAP */ - -1, /* RT_CMAPENTRY */ - -1, /* RT_OTHERCLIENT */ - -1 /* RT_PASSIVEGRAB */ }; - -static int *offsets = NULL; -static int offsetsSize = 0; -/* - * Specify where the devPrivates field is located in a structure type - */ -int -dixRegisterPrivateOffset(RESTYPE type, int offset) -{ - type = type & TypeMask; - - /* resize offsets table if necessary */ - while (type >= offsetsSize) { - unsigned i = offsetsSize * 2 * sizeof(int); - offsets = (int *)realloc(offsets, i); - if (!offsets) { - offsetsSize = 0; - return FALSE; - } - for (i=offsetsSize; i < 2*offsetsSize; i++) - offsets[i] = -1; - offsetsSize *= 2; - } - - offsets[type] = offset; - return TRUE; -} +#define NUM_OFFSETS (sizeof (offsets) / sizeof (offsets[0])) int dixLookupPrivateOffset(RESTYPE type) { + /* + * Special kludge for DBE which registers a new resource type that + * points at pixmaps (thanks, DBE) + */ + if (type & RC_DRAWABLE) { + if (type == RT_WINDOW) + return offsets[RT_WINDOW & TypeMask]; + else + return offsets[RT_PIXMAP & TypeMask]; + } type = type & TypeMask; - assert(type < offsetsSize); - return offsets[type]; + if (type < NUM_OFFSETS) + return offsets[type]; + return -1; } int @@ -268,15 +250,5 @@ dixResetPrivates(void) items[i].size = 0; } nextPriv = 1; - - /* reset offsets */ - if (offsets) - free(offsets); - offsetsSize = sizeof(offsetDefaults); - offsets = malloc(offsetsSize); - offsetsSize /= sizeof(int); - if (!offsets) - return FALSE; - memcpy(offsets, offsetDefaults, sizeof(offsetDefaults)); return TRUE; } diff --git a/dix/resource.c b/dix/resource.c index a6d115f65..ce025f9f0 100644 --- a/dix/resource.c +++ b/dix/resource.c @@ -254,8 +254,6 @@ CreateNewResourceType(DeleteType deleteFunc, char *name) types = realloc(resourceTypes, (next + 1) * sizeof(*resourceTypes)); if (!types) return 0; - if (!dixRegisterPrivateOffset(next, -1)) - return 0; lastResourceType = next; resourceTypes = types; diff --git a/include/privates.h b/include/privates.h index 7850dea6d..72f4d4028 100644 --- a/include/privates.h +++ b/include/privates.h @@ -107,26 +107,16 @@ dixFreePrivates(PrivateRec *privates); extern _X_EXPORT int dixResetPrivates(void); -/* - * These next two functions are necessary because the position of - * the devPrivates field varies by structure and calling code might - * only know the resource type, not the structure definition. - */ - /* * Looks up the offset where the devPrivates field is located. - * Returns -1 if no offset has been registered for the resource type. + * Returns -1 if the specified resource has no dev privates. + * The position of the devPrivates field varies by structure + * and calling code might only know the resource type, not the + * structure definition. */ extern _X_EXPORT int dixLookupPrivateOffset(RESTYPE type); -/* - * Specifies the offset where the devPrivates field is located. - * A negative value indicates no devPrivates field is available. - */ -extern _X_EXPORT int -dixRegisterPrivateOffset(RESTYPE type, int offset); - /* * Convenience macro for adding an offset to an object pointer * when making a call to one of the devPrivates functions