[PATCH 4/4] devPrivates rework: hook up to resource system

Eamon Walsh ewalsh at tycho.nsa.gov
Thu Feb 22 16:09:40 PST 2007


Hooks up the new interface in resource.c/main.c.  Also adds a
dixAddResource() that takes the additional screen parameter.

---
 dix/main.c                 |    1 +
 dix/resource.c             |   22 ++++++++++++++++------
 hw/xfree86/loader/dixsym.c |    1 +
 include/resource.h         |    6 ++++++
 4 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/dix/main.c b/dix/main.c
index 3a77533..92bda45 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -356,6 +356,7 @@ main(int argc, char *argv[], char *envp[])
 	InitAtoms();
 	InitEvents();
 	InitGlyphCaching();
+	dixResetPrivates();
 	ResetExtensionPrivates();
 	ResetClientPrivates();
 	ResetScreenPrivates();
diff --git a/dix/resource.c b/dix/resource.c
index 584ac94..9fffdd8 100644
--- a/dix/resource.c
+++ b/dix/resource.c
@@ -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, 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);
diff --git a/hw/xfree86/loader/dixsym.c b/hw/xfree86/loader/dixsym.c
index 9136351..7735767 100644
--- a/hw/xfree86/loader/dixsym.c
+++ b/hw/xfree86/loader/dixsym.c
@@ -283,6 +283,7 @@ _X_HIDDEN void *dixLookupTab[] = {
 #endif
     /* resource.c */
     SYMFUNC(AddResource)
+    SYMFUNC(dixAddResource)
     SYMFUNC(ChangeResourceValue)
     SYMFUNC(CreateNewResourceClass)
     SYMFUNC(CreateNewResourceType)
diff --git a/include/resource.h b/include/resource.h
index e635432..50f84b6 100644
--- a/include/resource.h
+++ b/include/resource.h
@@ -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*/);
-- 1.4.4.2




More information about the xorg mailing list