X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fhash.c;h=72d924dcc38ef222a4c9bea6ace6b5e99217446a;hb=d9e591391d490c83ce301aa568a2e0afe4cc3c0a;hp=7c3c7a6bdbb8533b97eaf97c2ac53c6430ca6339;hpb=693f4af63dd98b963e91259029cc0131b791721c;p=mesa.git diff --git a/src/mesa/main/hash.c b/src/mesa/main/hash.c index 7c3c7a6bdbb..72d924dcc38 100644 --- a/src/mesa/main/hash.c +++ b/src/mesa/main/hash.c @@ -108,27 +108,23 @@ _mesa_DeleteHashTable(struct _mesa_HashTable *table) _mesa_problem(NULL, "In _mesa_DeleteHashTable, found non-freed data"); } - _mesa_free(entry); + free(entry); entry = next; } } _glthread_DESTROY_MUTEX(table->Mutex); _glthread_DESTROY_MUTEX(table->WalkMutex); - _mesa_free(table); + free(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(const struct _mesa_HashTable *table, GLuint key) +static INLINE void * +_mesa_HashLookup_unlocked(struct _mesa_HashTable *table, GLuint key) { GLuint pos; const struct HashEntry *entry; @@ -140,7 +136,7 @@ _mesa_HashLookup(const struct _mesa_HashTable *table, GLuint key) entry = table->Table[pos]; while (entry) { if (entry->Key == key) { - return entry->Data; + return entry->Data; } entry = entry->Next; } @@ -148,6 +144,25 @@ _mesa_HashLookup(const struct _mesa_HashTable *table, GLuint key) } +/** + * 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. @@ -242,7 +257,7 @@ _mesa_HashRemove(struct _mesa_HashTable *table, GLuint key) else { table->Table[pos] = entry->Next; } - _mesa_free(entry); + free(entry); _glthread_UNLOCK_MUTEX(table->Mutex); return; } @@ -262,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, @@ -279,7 +294,7 @@ _mesa_HashDeleteAll(struct _mesa_HashTable *table, for (entry = table->Table[pos]; entry; entry = next) { callback(entry->Key, entry->Data, userData); next = entry->Next; - _mesa_free(entry); + free(entry); } table->Table[pos] = NULL; } @@ -298,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, @@ -444,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;