dix: don't use a local wrapper for calling HashResourceID
Calls to Hash(client, id) were replaced with calls directly to HashResourceID(id, clientTable[client].hashsize) and the Hash-function was removed. Signed-off-by: Erkki Seppälä <erkki.seppala@vincit.fi>
This commit is contained in:
parent
a0b0fb83f9
commit
a2ac01a8ea
|
@ -655,13 +655,13 @@ HashResourceID(XID id, int numBits)
|
|||
case 11:
|
||||
return ((int)(0x7FF & (id ^ (id>>11))));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
Hash(int client, XID id)
|
||||
{
|
||||
return HashResourceID(id, clientTable[client].hashsize);
|
||||
if (numBits >= 11)
|
||||
return ((int)(0x7FF & (id ^ (id>>11))));
|
||||
else
|
||||
{
|
||||
assert(numBits >= 0);
|
||||
return id & ~((~0) << numBits);
|
||||
}
|
||||
}
|
||||
|
||||
static XID
|
||||
|
@ -672,7 +672,7 @@ AvailableID(int client, XID id, XID maxid, XID goodid)
|
|||
if ((goodid >= id) && (goodid <= maxid))
|
||||
return goodid;
|
||||
for (; id <= maxid; id++) {
|
||||
res = clientTable[client].resources[Hash(client, id)];
|
||||
res = clientTable[client].resources[HashResourceID(id, clientTable[client].hashsize)];
|
||||
while (res && (res->id != id))
|
||||
res = res->next;
|
||||
if (!res)
|
||||
|
@ -798,7 +798,7 @@ AddResource(XID id, RESTYPE type, pointer value)
|
|||
}
|
||||
if ((rrec->elements >= 4 * rrec->buckets) && (rrec->hashsize < MAXHASHSIZE))
|
||||
RebuildTable(client);
|
||||
head = &rrec->resources[Hash(client, id)];
|
||||
head = &rrec->resources[HashResourceID(id, clientTable[client].hashsize)];
|
||||
res = malloc(sizeof(ResourceRec));
|
||||
if (!res) {
|
||||
(*resourceTypes[type & TypeMask].deleteFunc) (value, id);
|
||||
|
@ -846,7 +846,7 @@ RebuildTable(int client)
|
|||
for (res = *rptr; res; res = next) {
|
||||
next = res->next;
|
||||
res->next = NULL;
|
||||
tptr = &tails[Hash(client, res->id)];
|
||||
tptr = &tails[HashResourceID(res->id, clientTable[client].hashsize)];
|
||||
**tptr = res;
|
||||
*tptr = &res->next;
|
||||
}
|
||||
|
@ -878,7 +878,7 @@ FreeResource(XID id, RESTYPE skipDeleteFuncType)
|
|||
int elements;
|
||||
|
||||
if (((cid = CLIENT_ID(id)) < MAXCLIENTS) && clientTable[cid].buckets) {
|
||||
head = &clientTable[cid].resources[Hash(cid, id)];
|
||||
head = &clientTable[cid].resources[HashResourceID(id, clientTable[cid].hashsize)];
|
||||
eltptr = &clientTable[cid].elements;
|
||||
|
||||
prev = head;
|
||||
|
@ -912,7 +912,7 @@ FreeResourceByType(XID id, RESTYPE type, Bool skipFree)
|
|||
ResourcePtr *prev, *head;
|
||||
|
||||
if (((cid = CLIENT_ID(id)) < MAXCLIENTS) && clientTable[cid].buckets) {
|
||||
head = &clientTable[cid].resources[Hash(cid, id)];
|
||||
head = &clientTable[cid].resources[HashResourceID(id, clientTable[cid].hashsize)];
|
||||
|
||||
prev = head;
|
||||
while ((res = *prev)) {
|
||||
|
@ -947,7 +947,7 @@ ChangeResourceValue(XID id, RESTYPE rtype, pointer value)
|
|||
ResourcePtr res;
|
||||
|
||||
if (((cid = CLIENT_ID(id)) < MAXCLIENTS) && clientTable[cid].buckets) {
|
||||
res = clientTable[cid].resources[Hash(cid, id)];
|
||||
res = clientTable[cid].resources[HashResourceID(id, clientTable[cid].hashsize)];
|
||||
|
||||
for (; res; res = res->next)
|
||||
if ((res->id == id) && (res->type == rtype)) {
|
||||
|
@ -1185,7 +1185,7 @@ dixLookupResourceByType(pointer *result, XID id, RESTYPE rtype,
|
|||
return BadImplementation;
|
||||
|
||||
if ((cid < MAXCLIENTS) && clientTable[cid].buckets) {
|
||||
res = clientTable[cid].resources[Hash(cid, id)];
|
||||
res = clientTable[cid].resources[HashResourceID(id, clientTable[cid].hashsize)];
|
||||
|
||||
for (; res; res = res->next)
|
||||
if (res->id == id && res->type == rtype)
|
||||
|
@ -1218,7 +1218,7 @@ dixLookupResourceByClass(pointer *result, XID id, RESTYPE rclass,
|
|||
*result = NULL;
|
||||
|
||||
if ((cid < MAXCLIENTS) && clientTable[cid].buckets) {
|
||||
res = clientTable[cid].resources[Hash(cid, id)];
|
||||
res = clientTable[cid].resources[HashResourceID(id, clientTable[cid].hashsize)];
|
||||
|
||||
for (; res; res = res->next)
|
||||
if (res->id == id && (res->type & rclass))
|
||||
|
|
|
@ -275,10 +275,12 @@ extern _X_EXPORT RESTYPE TypeMask;
|
|||
/** @brief A hashing function to be used for hashing resource IDs
|
||||
|
||||
@param id The resource ID to hash
|
||||
@param numBits The number of bits in the resulting hash
|
||||
@param numBits The number of bits in the resulting hash. Must be >=0.
|
||||
|
||||
@note This function can only handle INITHASHSIZE..MAXHASHSIZE bit
|
||||
hashes and will return -1 if numBits is not within those bounds.
|
||||
@note This function is really only for handling
|
||||
INITHASHSIZE..MAXHASHSIZE bit hashes, but will handle any number
|
||||
of bits by either masking numBits lower bits of the ID or by
|
||||
providing at most MAXHASHSIZE hashes.
|
||||
*/
|
||||
extern _X_EXPORT int HashResourceID(XID id,
|
||||
int numBits);
|
||||
|
|
Loading…
Reference in New Issue
Block a user