From f203a9f7d1a7fc4cf41b35a477eb1f3699418fe3 Mon Sep 17 00:00:00 2001 From: Thomas Helland Date: Thu, 18 May 2017 20:39:20 +0200 Subject: [PATCH] main: Use _mesa_HashLock/UnlockMutex consistently This is shorter and easier on the eyes. At the same time this also ensures that we are always asserting that the table pointer is not NULL. Currently that was not done for all situations. Reviewed-by: Samuel Pitoiset Reviewed-by: Timothy Arceri --- src/mesa/main/hash.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/mesa/main/hash.c b/src/mesa/main/hash.c index 5b9132a3115..e352a46aa4b 100644 --- a/src/mesa/main/hash.c +++ b/src/mesa/main/hash.c @@ -205,10 +205,9 @@ void * _mesa_HashLookup(struct _mesa_HashTable *table, GLuint key) { void *res; - assert(table); - mtx_lock(&table->Mutex); + _mesa_HashLockMutex(table); res = _mesa_HashLookup_unlocked(table, key); - mtx_unlock(&table->Mutex); + _mesa_HashUnlockMutex(table); return res; } @@ -315,10 +314,9 @@ _mesa_HashInsertLocked(struct _mesa_HashTable *table, GLuint key, void *data) void _mesa_HashInsert(struct _mesa_HashTable *table, GLuint key, void *data) { - assert(table); - mtx_lock(&table->Mutex); + _mesa_HashLockMutex(table); _mesa_HashInsert_unlocked(table, key, data); - mtx_unlock(&table->Mutex); + _mesa_HashUnlockMutex(table); } @@ -364,9 +362,9 @@ _mesa_HashRemoveLocked(struct _mesa_HashTable *table, GLuint key) void _mesa_HashRemove(struct _mesa_HashTable *table, GLuint key) { - mtx_lock(&table->Mutex); + _mesa_HashLockMutex(table); _mesa_HashRemove_unlocked(table, key); - mtx_unlock(&table->Mutex); + _mesa_HashUnlockMutex(table); } /** @@ -385,9 +383,8 @@ _mesa_HashDeleteAll(struct _mesa_HashTable *table, { struct hash_entry *entry; - assert(table); assert(callback); - mtx_lock(&table->Mutex); + _mesa_HashLockMutex(table); table->InDeleteAll = GL_TRUE; hash_table_foreach(table->ht, entry) { callback((uintptr_t)entry->key, entry->data, userData); @@ -398,7 +395,7 @@ _mesa_HashDeleteAll(struct _mesa_HashTable *table, table->deleted_key_data = NULL; } table->InDeleteAll = GL_FALSE; - mtx_unlock(&table->Mutex); + _mesa_HashUnlockMutex(table); } @@ -434,9 +431,9 @@ _mesa_HashWalk(const struct _mesa_HashTable *table, /* cast-away const */ struct _mesa_HashTable *table2 = (struct _mesa_HashTable *) table; - mtx_lock(&table2->Mutex); + _mesa_HashLockMutex(table2); hash_walk_unlocked(table, callback, userData); - mtx_unlock(&table2->Mutex); + _mesa_HashUnlockMutex(table2); } void -- 2.30.2