On 05.04.2011 17:54, Keith Packard wrote:
Internally resource.c now uses the same static function Hash implemented
in terms of HashResourceID.
Please just fix users of the existing 'Hash' function to call
HashResourceID directly.
Hm, are you sure? It looks like this afterwards:
diff --git a/dix/resource.c b/dix/resource.c
index aa98c1e..071fa2e 100644
--- a/dix/resource.c
+++ b/dix/resource.c
@@ -689 +689 @@ AvailableID(
- res = clientTable[client].resources[Hash(client, id)];
+ res = clientTable[client].resources[HashResourceID(id,
clientTable[client].hashsize)];
@@ -821 +821 @@ AddResource(XID id, RESTYPE type, pointer value)
- head = &rrec->resources[Hash(client, id)];
+ head = &rrec->resources[HashResourceID(id, clientTable[client].hashsize)];
@@ -876 +876 @@ RebuildTable(int client)
- tptr = &tails[Hash(client, res->id)];
+ tptr = &tails[HashResourceID(res->id, clientTable[client].hashsize)];
@@ -909 +909 @@ FreeResource(XID id, RESTYPE skipDeleteFuncType)
- head = &clientTable[cid].resources[Hash(cid, id)];
+ head = &clientTable[cid].resources[HashResourceID(id,
clientTable[cid].hashsize)];
@@ -945 +945 @@ FreeResourceByType(XID id, RESTYPE type, Bool skipFree)
- head = &clientTable[cid].resources[Hash(cid, id)];
+ head = &clientTable[cid].resources[HashResourceID(id,
clientTable[cid].hashsize)];
@@ -983 +983 @@ ChangeResourceValue (XID id, RESTYPE rtype, pointer value)
- res = clientTable[cid].resources[Hash(cid, id)];
+ res = clientTable[cid].resources[HashResourceID(id,
clientTable[cid].hashsize)];
@@ -1243 +1243 @@ dixLookupResourceByType(pointer *result, XID id,
RESTYPE rtype,
- res = clientTable[cid].resources[Hash(cid, id)];
+ res = clientTable[cid].resources[HashResourceID(id,
clientTable[cid].hashsize)];
@@ -1276 +1276 @@ dixLookupResourceByClass(pointer *result, XID id,
RESTYPE rclass,
- res = clientTable[cid].resources[Hash(cid, id)];
+ res = clientTable[cid].resources[HashResourceID(id,
clientTable[cid].hashsize)];
Or just use case 11: as the default; that would work for any accidental
increases in the client hashsize value. What an ugly function. I like to
avoid power-of-two hash tables and use prime sizes to ensure reasonable
distribution instead of relying on hash value tricks.
That's indeed a better solution for an ugly problem, I'll revise the code.
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel