devPrivates rework: redo field offset registration, drop RC_PRIVATES class.
This commit is contained in:
parent
947f8d249b
commit
2fcb45eb5d
|
@ -195,12 +195,14 @@ dixRegisterPrivateOffset(RESTYPE type, unsigned offset)
|
|||
|
||||
/* resize offsets table if necessary */
|
||||
while (type >= offsetsSize) {
|
||||
offsets = (unsigned *)xrealloc(offsets,
|
||||
offsetsSize * 2 * sizeof(unsigned));
|
||||
unsigned i = offsetsSize * 2 * sizeof(int);
|
||||
offsets = (unsigned *)xrealloc(offsets, i);
|
||||
if (!offsets) {
|
||||
offsetsSize = 0;
|
||||
return FALSE;
|
||||
}
|
||||
for (i=offsetsSize; i < 2*offsetsSize; i++)
|
||||
offsets[i] = -1;
|
||||
offsetsSize *= 2;
|
||||
}
|
||||
|
||||
|
@ -208,10 +210,9 @@ dixRegisterPrivateOffset(RESTYPE type, unsigned offset)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
_X_EXPORT unsigned
|
||||
_X_EXPORT int
|
||||
dixLookupPrivateOffset(RESTYPE type)
|
||||
{
|
||||
assert(type & RC_PRIVATES);
|
||||
type = type & TypeMask;
|
||||
assert(type < offsetsSize);
|
||||
return offsets[type];
|
||||
|
@ -233,19 +234,22 @@ int
|
|||
dixResetPrivates(void)
|
||||
{
|
||||
PrivateDescRec *next;
|
||||
unsigned i;
|
||||
|
||||
/* reset internal structures */
|
||||
while (items) {
|
||||
next = items->next;
|
||||
xfree(items);
|
||||
items = next;
|
||||
}
|
||||
|
||||
if (offsets)
|
||||
xfree(offsets);
|
||||
|
||||
offsetsSize = 16;
|
||||
offsets = (unsigned *)xalloc(offsetsSize * sizeof(unsigned));
|
||||
if (!offsets)
|
||||
return FALSE;
|
||||
for (i=0; i < offsetsSize; i++)
|
||||
offsets[i] = -1;
|
||||
|
||||
/* reset legacy devPrivates support */
|
||||
if (!ResetExtensionPrivates() || !ResetClientPrivates())
|
||||
|
|
|
@ -142,9 +142,10 @@ dixResetPrivates(void);
|
|||
*/
|
||||
|
||||
/*
|
||||
* Looks up the offset where the devPrivates field is located by type.
|
||||
* Looks up the offset where the devPrivates field is located.
|
||||
* Returns -1 if no offset has been registered for the resource type.
|
||||
*/
|
||||
extern unsigned
|
||||
extern int
|
||||
dixLookupPrivateOffset(RESTYPE type);
|
||||
|
||||
/*
|
||||
|
|
|
@ -66,12 +66,7 @@ typedef unsigned long RESTYPE;
|
|||
* Extensions can use this too!
|
||||
*/
|
||||
#define RC_NEVERRETAIN ((RESTYPE)1<<29)
|
||||
/* Use class RC_PRIVATES for resources that support extra private data.
|
||||
* Resources having this class must provide a field of type PrivateRec *.
|
||||
* Refer to the X server documentation on devPrivates for the details.
|
||||
*/
|
||||
#define RC_PRIVATES ((RESTYPE)1<<28)
|
||||
#define RC_LASTPREDEF RC_PRIVATES
|
||||
#define RC_LASTPREDEF RC_NEVERRETAIN
|
||||
#define RC_ANY (~(RESTYPE)0)
|
||||
|
||||
/* types for Resource routines */
|
||||
|
|
Loading…
Reference in New Issue
Block a user