Added few more stubs so that control reaches to DestroyDevice().
[mesa.git] / src / util / set.c
index 4788b94324a3f00fe1dc318ef238e1ed12003048..a9012b4e6d4c6407cbf0d2a70a77d30b32feda58 100644 (file)
@@ -92,6 +92,12 @@ static const struct {
    ENTRY(2147483648ul, 2362232233ul, 2362232231ul )
 };
 
+ASSERTED static inline bool
+key_pointer_is_reserved(const void *key)
+{
+   return key == NULL || key == deleted_key;
+}
+
 static int
 entry_is_free(struct set_entry *entry)
 {
@@ -214,6 +220,8 @@ _mesa_set_clear(struct set *set, void (*delete_function)(struct set_entry *entry
 static struct set_entry *
 set_search(const struct set *ht, uint32_t hash, const void *key)
 {
+   assert(!key_pointer_is_reserved(key));
+
    uint32_t size = ht->size;
    uint32_t start_address = util_fast_urem32(hash, size, ht->size_magic);
    uint32_t double_hash = util_fast_urem32(hash, ht->rehash,
@@ -337,6 +345,8 @@ set_search_or_add(struct set *ht, uint32_t hash, const void *key, bool *found)
 {
    struct set_entry *available_entry = NULL;
 
+   assert(!key_pointer_is_reserved(key));
+
    if (ht->entries >= ht->max_entries) {
       set_rehash(ht, ht->size_index + 1);
    } else if (ht->deleted_entries + ht->entries >= ht->max_entries) {
@@ -560,3 +570,23 @@ _mesa_pointer_set_create(void *mem_ctx)
    return _mesa_set_create(mem_ctx, _mesa_hash_pointer,
                            _mesa_key_pointer_equal);
 }
+
+bool
+_mesa_set_intersects(struct set *a, struct set *b)
+{
+   assert(a->key_hash_function == b->key_hash_function);
+   assert(a->key_equals_function == b->key_equals_function);
+
+   /* iterate over the set with less entries */
+   if (b->entries < a->entries) {
+      struct set *tmp = a;
+      a = b;
+      b = tmp;
+   }
+
+   set_foreach(a, entry) {
+      if (_mesa_set_search_pre_hashed(b, entry->hash, entry->key))
+         return true;
+   }
+   return false;
+}