diff options
author | Mike Stroyan <mike@LunarG.com> | 2010-02-16 08:18:12 -0700 |
---|---|---|
committer | Brian Paul <brianp@vmware.com> | 2010-02-16 08:18:12 -0700 |
commit | 3094adb3caeb90124359db2356df3bf8ee94800a (patch) | |
tree | 8f6a93cf1c5bf3d69764eed5bbe36800401a3328 /src/mesa | |
parent | 7c7247ddbf6e3f7f93e44c1cb52490044f1a2215 (diff) |
mesa: Lock mutex around _mesa_HashLookup linked list chase.
Remove const qualifier from _mesa_HashLookup() table parameter to
avoid LOCK/UNLOCK warnings in the function body.
Signed-off-by: Brian Paul <brianp@vmware.com>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/main/hash.c | 7 | ||||
-rw-r--r-- | src/mesa/main/hash.h | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/mesa/main/hash.c b/src/mesa/main/hash.c index 7c3c7a6bdbb..fdfbe6b4f43 100644 --- a/src/mesa/main/hash.c +++ b/src/mesa/main/hash.c @@ -128,7 +128,7 @@ _mesa_DeleteHashTable(struct _mesa_HashTable *table) * \return pointer to user's data or NULL if key not in table */ void * -_mesa_HashLookup(const struct _mesa_HashTable *table, GLuint key) +_mesa_HashLookup(struct _mesa_HashTable *table, GLuint key) { GLuint pos; const struct HashEntry *entry; @@ -137,13 +137,16 @@ _mesa_HashLookup(const 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) { - return entry->Data; + _glthread_UNLOCK_MUTEX(table->Mutex); + return entry->Data; } entry = entry->Next; } + _glthread_UNLOCK_MUTEX(table->Mutex); return NULL; } diff --git a/src/mesa/main/hash.h b/src/mesa/main/hash.h index d18db76abe1..4f916f9d01f 100644 --- a/src/mesa/main/hash.h +++ b/src/mesa/main/hash.h @@ -39,7 +39,7 @@ extern struct _mesa_HashTable *_mesa_NewHashTable(void); extern void _mesa_DeleteHashTable(struct _mesa_HashTable *table); -extern void *_mesa_HashLookup(const struct _mesa_HashTable *table, GLuint key); +extern void *_mesa_HashLookup(struct _mesa_HashTable *table, GLuint key); extern void _mesa_HashInsert(struct _mesa_HashTable *table, GLuint key, void *data); |