[PATCH] dix: Small refactor to resource deletion
Adam Jackson
ajax at redhat.com
Thu Mar 24 13:52:56 PDT 2011
Signed-off-by: Adam Jackson <ajax at redhat.com>
---
dix/resource.c | 34 ++++++++++++++++------------------
1 files changed, 16 insertions(+), 18 deletions(-)
diff --git a/dix/resource.c b/dix/resource.c
index 26d2c72..a04f49f 100644
--- a/dix/resource.c
+++ b/dix/resource.c
@@ -562,6 +562,17 @@ RebuildTable(int client)
clientTable[client].resources = resources;
}
+static void
+doFreeResource(ResourcePtr res, Bool skip)
+{
+ CallResourceStateCallback(ResourceStateFreeing, res);
+
+ if (!skip)
+ resourceTypes[res->type & TypeMask].deleteFunc(res->value, res->id);
+
+ free(res);
+}
+
void
FreeResource(XID id, RESTYPE skipDeleteFuncType)
{
@@ -590,11 +601,8 @@ FreeResource(XID id, RESTYPE skipDeleteFuncType)
*prev = res->next;
elements = --*eltptr;
- CallResourceStateCallback(ResourceStateFreeing, res);
+ doFreeResource(res, rtype == skipDeleteFuncType);
- if (rtype != skipDeleteFuncType)
- (*resourceTypes[rtype & TypeMask].deleteFunc)(res->value, res->id);
- free(res);
if (*eltptr != elements)
prev = head; /* prev may no longer be valid */
}
@@ -604,7 +612,6 @@ FreeResource(XID id, RESTYPE skipDeleteFuncType)
}
}
-
void
FreeResourceByType(XID id, RESTYPE type, Bool skipFree)
{
@@ -627,11 +634,8 @@ FreeResourceByType(XID id, RESTYPE type, Bool skipFree)
*prev = res->next;
clientTable[cid].elements--;
- CallResourceStateCallback(ResourceStateFreeing, res);
+ doFreeResource(res, skipFree);
- if (!skipFree)
- (*resourceTypes[type & TypeMask].deleteFunc)(res->value, res->id);
- free(res);
break;
}
else
@@ -793,12 +797,10 @@ FreeClientNeverRetainResources(ClientPtr client)
#endif
*prev = this->next;
clientTable[client->index].elements--;
+ elements = *eltptr;
- CallResourceStateCallback(ResourceStateFreeing, this);
+ doFreeResource(this, FALSE);
- elements = *eltptr;
- (*resourceTypes[rtype & TypeMask].deleteFunc)(this->value, this->id);
- free(this);
if (*eltptr != elements)
prev = &resources[j]; /* prev may no longer be valid */
}
@@ -841,7 +843,6 @@ FreeClientResources(ClientPtr client)
for (this = *head; this; this = *head)
{
- RESTYPE rtype = this->type;
#ifdef XSERVER_DTRACE
XSERVER_RESOURCE_FREE(this->id, this->type,
this->value, TypeNameString(this->type));
@@ -849,10 +850,7 @@ FreeClientResources(ClientPtr client)
*head = this->next;
clientTable[client->index].elements--;
- CallResourceStateCallback(ResourceStateFreeing, this);
-
- (*resourceTypes[rtype & TypeMask].deleteFunc)(this->value, this->id);
- free(this);
+ doFreeResource(this, FALSE);
}
}
free(clientTable[client->index].resources);
--
1.7.4
More information about the xorg-devel
mailing list