X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmesa%2Fmain%2Fhash.c;h=4b250ad546874c6cfb0d5600789b93026f7d25db;hb=8fe6755ed52acfb88a7a787c3406b64fcdd80e6e;hp=975775469d94e5f0e74afd790c08d3ab037fde50;hpb=32f2fd1c5d6088692551c80352b7d6fa35b0cd09;p=mesa.git diff --git a/src/mesa/main/hash.c b/src/mesa/main/hash.c index 975775469d9..4b250ad5468 100644 --- a/src/mesa/main/hash.c +++ b/src/mesa/main/hash.c @@ -120,15 +120,11 @@ _mesa_DeleteHashTable(struct _mesa_HashTable *table) /** - * Lookup an entry in the hash table. - * - * \param table the hash table. - * \param key the key. - * - * \return pointer to user's data or NULL if key not in table + * Lookup an entry in the hash table, without locking. + * \sa _mesa_HashLookup */ -void * -_mesa_HashLookup(struct _mesa_HashTable *table, GLuint key) +static inline void * +_mesa_HashLookup_unlocked(struct _mesa_HashTable *table, GLuint key) { GLuint pos; const struct HashEntry *entry; @@ -137,20 +133,36 @@ _mesa_HashLookup(struct _mesa_HashTable *table, GLuint key) assert(key); pos = HASH_FUNC(key); - _glthread_LOCK_MUTEX(table->Mutex); entry = table->Table[pos]; while (entry) { if (entry->Key == key) { - _glthread_UNLOCK_MUTEX(table->Mutex); return entry->Data; } entry = entry->Next; } - _glthread_UNLOCK_MUTEX(table->Mutex); return NULL; } +/** + * Lookup an entry in the hash table. + * + * \param table the hash table. + * \param key the key. + * + * \return pointer to user's data or NULL if key not in table + */ +void * +_mesa_HashLookup(struct _mesa_HashTable *table, GLuint key) +{ + void *res; + assert(table); + _glthread_LOCK_MUTEX(table->Mutex); + res = _mesa_HashLookup_unlocked(table, key); + _glthread_UNLOCK_MUTEX(table->Mutex); + return res; +} + /** * Insert a key/pointer pair into the hash table. @@ -265,7 +277,7 @@ _mesa_HashRemove(struct _mesa_HashTable *table, GLuint key) * \param table the hash table to delete * \param callback the callback function * \param userData arbitrary pointer to pass along to the callback - * (this is typically a GLcontext pointer) + * (this is typically a struct gl_context pointer) */ void _mesa_HashDeleteAll(struct _mesa_HashTable *table, @@ -301,7 +313,7 @@ _mesa_HashDeleteAll(struct _mesa_HashTable *table, * \param table the hash table to walk * \param callback the callback function * \param userData arbitrary pointer to pass along to the callback - * (this is typically a GLcontext pointer) + * (this is typically a struct gl_context pointer) */ void _mesa_HashWalk(const struct _mesa_HashTable *table, @@ -447,7 +459,7 @@ _mesa_HashFindFreeKeyBlock(struct _mesa_HashTable *table, GLuint numKeys) GLuint freeStart = 1; GLuint key; for (key = 1; key != maxKey; key++) { - if (_mesa_HashLookup(table, key)) { + if (_mesa_HashLookup_unlocked(table, key)) { /* darn, this key is already in use */ freeCount = 0; freeStart = key+1;