summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/hash.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main/hash.c')
-rw-r--r--src/mesa/main/hash.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/mesa/main/hash.c b/src/mesa/main/hash.c
index 88e94e7884d..cbd7f551350 100644
--- a/src/mesa/main/hash.c
+++ b/src/mesa/main/hash.c
@@ -1,4 +1,4 @@
-/* $Id: hash.c,v 1.7 2000/01/31 23:11:39 brianp Exp $ */
+/* $Id: hash.c,v 1.8 2000/03/21 17:42:27 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -203,17 +203,21 @@ void _mesa_HashRemove(struct _mesa_HashTable *table, GLuint key)
/*
* Return the key of the "first" entry in the hash table.
- * By calling this function until zero is returned we can get
- * the keys of all entries in the table.
+ * This is used in the course of deleting all display lists when
+ * a context is destroyed.
*/
GLuint _mesa_HashFirstEntry(const struct _mesa_HashTable *table)
{
GLuint pos;
assert(table);
+ _glthread_LOCK_MUTEX(table->Mutex);
for (pos=0; pos < TABLE_SIZE; pos++) {
- if (table->Table[pos])
+ if (table->Table[pos]) {
+ _glthread_UNLOCK_MUTEX(table->Mutex);
return table->Table[pos]->Key;
+ }
}
+ _glthread_UNLOCK_MUTEX(table->Mutex);
return 0;
}
@@ -246,8 +250,10 @@ void _mesa_HashPrint(const struct _mesa_HashTable *table)
GLuint _mesa_HashFindFreeKeyBlock(const struct _mesa_HashTable *table, GLuint numKeys)
{
GLuint maxKey = ~((GLuint) 0);
+ _glthread_LOCK_MUTEX(table->Mutex);
if (maxKey - numKeys > table->MaxKey) {
/* the quick solution */
+ _glthread_UNLOCK_MUTEX(table->Mutex);
return table->MaxKey + 1;
}
else {
@@ -265,11 +271,13 @@ GLuint _mesa_HashFindFreeKeyBlock(const struct _mesa_HashTable *table, GLuint nu
/* this key not in use, check if we've found enough */
freeCount++;
if (freeCount == numKeys) {
+ _glthread_UNLOCK_MUTEX(table->Mutex);
return freeStart;
}
}
}
/* cannot allocate a block of numKeys consecutive keys */
+ _glthread_UNLOCK_MUTEX(table->Mutex);
return 0;
}
}