mesa: don't leak performance monitors on context destroy
[mesa.git] / src / mesa / main / hash.c
index e38158c758d09af54624ed24aa00a9d4b89415ec..b31fd48390697087f0f5a8a7f5c3f16754e8ac2b 100644 (file)
@@ -12,7 +12,6 @@
 
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.1
  *
  * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
  *
@@ -302,6 +301,34 @@ _mesa_HashDeleteAll(struct _mesa_HashTable *table,
 }
 
 
+/**
+ * Clone all entries in a hash table, into a new table.
+ *
+ * \param table  the hash table to clone
+ */
+struct _mesa_HashTable *
+_mesa_HashClone(const struct _mesa_HashTable *table)
+{
+   /* cast-away const */
+   struct _mesa_HashTable *table2 = (struct _mesa_HashTable *) table;
+   struct hash_entry *entry;
+   struct _mesa_HashTable *clonetable;
+
+   ASSERT(table);
+   _glthread_LOCK_MUTEX(table2->Mutex);
+
+   clonetable = _mesa_NewHashTable();
+   assert(clonetable);
+   hash_table_foreach(table->ht, entry) {
+      _mesa_HashInsert(clonetable, (GLint)(uintptr_t)entry->key, entry->data);
+   }
+
+   _glthread_UNLOCK_MUTEX(table2->Mutex);
+
+   return clonetable;
+}
+
+
 /**
  * Walk over all entries in a hash table, calling callback function for each.
  * Note: we use a separate mutex in this function to avoid a recursive