devPrivates rework: hook up new interface in resource system; add new

resource-adding function that takes an additional ScreenPtr argument.
This commit is contained in:
Eamon Walsh 2007-02-23 13:23:12 -05:00 committed by Eamon Walsh
parent 16f2b8892d
commit 81372f9096
4 changed files with 25 additions and 6 deletions

View File

@ -89,6 +89,7 @@ Equipment Corporation.
#include "os.h"
#include "windowstr.h"
#include "resource.h"
#include "privates.h"
#include "dixstruct.h"
#include "gcstruct.h"
#include "extension.h"
@ -356,6 +357,7 @@ main(int argc, char *argv[], char *envp[])
InitAtoms();
InitEvents();
InitGlyphCaching();
dixResetPrivates();
ResetExtensionPrivates();
ResetClientPrivates();
ResetScreenPrivates();

View File

@ -135,6 +135,7 @@ Equipment Corporation.
#include "misc.h"
#include "os.h"
#include "resource.h"
#include "privates.h"
#include "dixstruct.h"
#include "opaque.h"
#include "windowstr.h"
@ -206,6 +207,8 @@ CreateNewResourceType(DeleteType deleteFunc)
if (next & lastResourceClass)
return 0;
if (!dixUpdatePrivates())
return 0;
funcs = (DeleteType *)xrealloc(DeleteFuncs,
(next + 1) * sizeof(DeleteType));
if (!funcs)
@ -451,7 +454,7 @@ FakeClientID(register int client)
}
_X_EXPORT Bool
AddResource(XID id, RESTYPE type, pointer value)
dixAddResource(XID id, RESTYPE type, pointer value, pointer parent)
{
int client;
register ClientResourceRec *rrec;
@ -472,7 +475,7 @@ AddResource(XID id, RESTYPE type, pointer value)
(rrec->hashsize < MAXHASHSIZE))
RebuildTable(client);
head = &rrec->resources[Hash(client, id)];
res = (ResourcePtr)xalloc(sizeof(ResourceRec));
res = dixAllocateResourceRec(type, value, parent);
if (!res)
{
(*DeleteFuncs[type & TypeMask])(value, id);
@ -486,9 +489,16 @@ AddResource(XID id, RESTYPE type, pointer value)
rrec->elements++;
if (!(id & SERVER_BIT) && (id >= rrec->expectID))
rrec->expectID = id + 1;
dixCallPrivateInitFuncs(res);
return TRUE;
}
_X_EXPORT Bool
AddResource(XID id, RESTYPE type, pointer value)
{
return dixAddResource(id, type, value, NULL);
}
static void
RebuildTable(int client)
{
@ -570,7 +580,7 @@ FreeResource(XID id, RESTYPE skipDeleteFuncType)
FlushClientCaches(res->id);
if (rtype != skipDeleteFuncType)
(*DeleteFuncs[rtype & TypeMask])(res->value, res->id);
xfree(res);
dixFreeResourceRec(res);
if (*eltptr != elements)
prev = head; /* prev may no longer be valid */
gotOne = TRUE;
@ -614,7 +624,7 @@ FreeResourceByType(XID id, RESTYPE type, Bool skipFree)
FlushClientCaches(res->id);
if (!skipFree)
(*DeleteFuncs[type & TypeMask])(res->value, res->id);
xfree(res);
dixFreeResourceRec(res);
break;
}
else
@ -779,7 +789,7 @@ FreeClientNeverRetainResources(ClientPtr client)
if (rtype & RC_CACHED)
FlushClientCaches(this->id);
(*DeleteFuncs[rtype & TypeMask])(this->value, this->id);
xfree(this);
dixFreeResourceRec(this);
}
else
prev = &this->next;
@ -829,7 +839,7 @@ FreeClientResources(ClientPtr client)
if (rtype & RC_CACHED)
FlushClientCaches(this->id);
(*DeleteFuncs[rtype & TypeMask])(this->value, this->id);
xfree(this);
dixFreeResourceRec(this);
}
}
xfree(clientTable[client->index].resources);

View File

@ -283,6 +283,7 @@ _X_HIDDEN void *dixLookupTab[] = {
#endif
/* resource.c */
SYMFUNC(AddResource)
SYMFUNC(dixAddResource)
SYMFUNC(ChangeResourceValue)
SYMFUNC(CreateNewResourceClass)
SYMFUNC(CreateNewResourceType)

View File

@ -183,6 +183,12 @@ extern Bool AddResource(
RESTYPE /*type*/,
pointer /*value*/);
extern Bool dixAddResource(
XID /*id*/,
RESTYPE /*type*/,
pointer /*value*/,
pointer /*parent*/);
extern void FreeResource(
XID /*id*/,
RESTYPE /*skipDeleteFuncType*/);