summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2011-03-24 16:51:54 -0400
committerAdam Jackson <ajax@redhat.com>2011-03-28 12:56:03 -0400
commitf1c2c01ac9ea7381cb4cd21ac1b2185ff28da3ec (patch)
treec76d6df1d45035d73f37135904117a3b8d421655
parent3e0b311aba54895d806174526511ef11b31432b1 (diff)
dix: Small refactor to resource deletion
Reviewed-by: Matt Turner <mattst88@gmail.com> Signed-off-by: Adam Jackson <ajax@redhat.com>
-rw-r--r--dix/resource.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/dix/resource.c b/dix/resource.c
index 26d2c72aa..a04f49f6d 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);