Lines Matching full:table
3 * Generic hash table.
43 * Create a new hash table.
45 * \return pointer to a new, empty hash table.
50 struct _mesa_HashTable *table = CALLOC_STRUCT(_mesa_HashTable); in _mesa_NewHashTable() local
52 if (table) { in _mesa_NewHashTable()
53 table->ht = _mesa_hash_table_create(NULL, uint_key_hash, in _mesa_NewHashTable()
55 if (table->ht == NULL) { in _mesa_NewHashTable()
56 free(table); in _mesa_NewHashTable()
61 _mesa_hash_table_set_deleted_key(table->ht, uint_key(DELETED_KEY_VALUE)); in _mesa_NewHashTable()
66 mtx_init(&table->Mutex, mtx_recursive); in _mesa_NewHashTable()
72 return table; in _mesa_NewHashTable()
78 * Delete a hash table.
79 * Frees each entry on the hash table and then the hash table structure itself.
80 * Note that the caller should have already traversed the table and deleted
81 * the objects in the table (i.e. We don't free the entries' data pointer).
83 * \param table the hash table to delete.
86 _mesa_DeleteHashTable(struct _mesa_HashTable *table) in _mesa_DeleteHashTable() argument
88 assert(table); in _mesa_DeleteHashTable()
90 if (_mesa_hash_table_next_entry(table->ht, NULL) != NULL) { in _mesa_DeleteHashTable()
94 _mesa_hash_table_destroy(table->ht, NULL); in _mesa_DeleteHashTable()
96 mtx_destroy(&table->Mutex); in _mesa_DeleteHashTable()
97 free(table); in _mesa_DeleteHashTable()
103 * Lookup an entry in the hash table, without locking.
107 _mesa_HashLookup_unlocked(struct _mesa_HashTable *table, GLuint key) in _mesa_HashLookup_unlocked() argument
111 assert(table); in _mesa_HashLookup_unlocked()
115 return table->deleted_key_data; in _mesa_HashLookup_unlocked()
117 entry = _mesa_hash_table_search_pre_hashed(table->ht, in _mesa_HashLookup_unlocked()
128 * Lookup an entry in the hash table.
130 * \param table the hash table.
133 * \return pointer to user's data or NULL if key not in table
136 _mesa_HashLookup(struct _mesa_HashTable *table, GLuint key) in _mesa_HashLookup() argument
139 _mesa_HashLockMutex(table); in _mesa_HashLookup()
140 res = _mesa_HashLookup_unlocked(table, key); in _mesa_HashLookup()
141 _mesa_HashUnlockMutex(table); in _mesa_HashLookup()
147 * Lookup an entry in the hash table without locking the mutex.
149 * The hash table mutex must be locked manually by calling
152 * \param table the hash table.
155 * \return pointer to user's data or NULL if key not in table
158 _mesa_HashLookupLocked(struct _mesa_HashTable *table, GLuint key) in _mesa_HashLookupLocked() argument
160 return _mesa_HashLookup_unlocked(table, key); in _mesa_HashLookupLocked()
165 _mesa_HashInsert_unlocked(struct _mesa_HashTable *table, GLuint key, void *data) in _mesa_HashInsert_unlocked() argument
170 assert(table); in _mesa_HashInsert_unlocked()
173 if (key > table->MaxKey) in _mesa_HashInsert_unlocked()
174 table->MaxKey = key; in _mesa_HashInsert_unlocked()
177 table->deleted_key_data = data; in _mesa_HashInsert_unlocked()
179 entry = _mesa_hash_table_search_pre_hashed(table->ht, hash, uint_key(key)); in _mesa_HashInsert_unlocked()
183 _mesa_hash_table_insert_pre_hashed(table->ht, hash, uint_key(key), data); in _mesa_HashInsert_unlocked()
190 * Insert a key/pointer pair into the hash table without locking the mutex.
193 * The hash table mutex must be locked manually by calling
196 * \param table the hash table.
201 _mesa_HashInsertLocked(struct _mesa_HashTable *table, GLuint key, void *data) in _mesa_HashInsertLocked() argument
203 _mesa_HashInsert_unlocked(table, key, data); in _mesa_HashInsertLocked()
208 * Insert a key/pointer pair into the hash table.
211 * \param table the hash table.
216 _mesa_HashInsert(struct _mesa_HashTable *table, GLuint key, void *data) in _mesa_HashInsert() argument
218 _mesa_HashLockMutex(table); in _mesa_HashInsert()
219 _mesa_HashInsert_unlocked(table, key, data); in _mesa_HashInsert()
220 _mesa_HashUnlockMutex(table); in _mesa_HashInsert()
225 * Remove an entry from the hash table.
227 * \param table the hash table.
230 * While holding the hash table's lock, searches the entry with the matching
234 _mesa_HashRemove_unlocked(struct _mesa_HashTable *table, GLuint key) in _mesa_HashRemove_unlocked() argument
238 assert(table); in _mesa_HashRemove_unlocked()
244 assert(!table->InDeleteAll); in _mesa_HashRemove_unlocked()
247 table->deleted_key_data = NULL; in _mesa_HashRemove_unlocked()
249 entry = _mesa_hash_table_search_pre_hashed(table->ht, in _mesa_HashRemove_unlocked()
252 _mesa_hash_table_remove(table->ht, entry); in _mesa_HashRemove_unlocked()
258 _mesa_HashRemoveLocked(struct _mesa_HashTable *table, GLuint key) in _mesa_HashRemoveLocked() argument
260 _mesa_HashRemove_unlocked(table, key); in _mesa_HashRemoveLocked()
264 _mesa_HashRemove(struct _mesa_HashTable *table, GLuint key) in _mesa_HashRemove() argument
266 _mesa_HashLockMutex(table); in _mesa_HashRemove()
267 _mesa_HashRemove_unlocked(table, key); in _mesa_HashRemove()
268 _mesa_HashUnlockMutex(table); in _mesa_HashRemove()
272 * Delete all entries in a hash table, but don't delete the table itself.
273 * Invoke the given callback function for each table entry.
275 * \param table the hash table to delete
281 _mesa_HashDeleteAll(struct _mesa_HashTable *table, in _mesa_HashDeleteAll() argument
288 _mesa_HashLockMutex(table); in _mesa_HashDeleteAll()
289 table->InDeleteAll = GL_TRUE; in _mesa_HashDeleteAll()
290 hash_table_foreach(table->ht, entry) { in _mesa_HashDeleteAll()
292 _mesa_hash_table_remove(table->ht, entry); in _mesa_HashDeleteAll()
294 if (table->deleted_key_data) { in _mesa_HashDeleteAll()
295 callback(DELETED_KEY_VALUE, table->deleted_key_data, userData); in _mesa_HashDeleteAll()
296 table->deleted_key_data = NULL; in _mesa_HashDeleteAll()
298 table->InDeleteAll = GL_FALSE; in _mesa_HashDeleteAll()
299 _mesa_HashUnlockMutex(table); in _mesa_HashDeleteAll()
304 * Walk over all entries in a hash table, calling callback function for each.
305 * \param table the hash table to walk
311 hash_walk_unlocked(const struct _mesa_HashTable *table, in hash_walk_unlocked() argument
315 assert(table); in hash_walk_unlocked()
319 hash_table_foreach(table->ht, entry) { in hash_walk_unlocked()
322 if (table->deleted_key_data) in hash_walk_unlocked()
323 callback(DELETED_KEY_VALUE, table->deleted_key_data, userData); in hash_walk_unlocked()
328 _mesa_HashWalk(const struct _mesa_HashTable *table, in _mesa_HashWalk() argument
333 struct _mesa_HashTable *table2 = (struct _mesa_HashTable *) table; in _mesa_HashWalk()
336 hash_walk_unlocked(table, callback, userData); in _mesa_HashWalk()
341 _mesa_HashWalkLocked(const struct _mesa_HashTable *table, in _mesa_HashWalkLocked() argument
345 hash_walk_unlocked(table, callback, userData); in _mesa_HashWalkLocked()
355 * Dump contents of hash table for debugging.
357 * \param table the hash table.
360 _mesa_HashPrint(const struct _mesa_HashTable *table) in _mesa_HashPrint() argument
362 if (table->deleted_key_data) in _mesa_HashPrint()
363 debug_print_entry(DELETED_KEY_VALUE, table->deleted_key_data, NULL); in _mesa_HashPrint()
364 _mesa_HashWalk(table, debug_print_entry, NULL); in _mesa_HashPrint()
371 * \param table the hash table.
376 * If there are enough free keys between the maximum key existing in the table
382 _mesa_HashFindFreeKeyBlock(struct _mesa_HashTable *table, GLuint numKeys) in _mesa_HashFindFreeKeyBlock() argument
385 if (maxKey - numKeys > table->MaxKey) { in _mesa_HashFindFreeKeyBlock()
387 return table->MaxKey + 1; in _mesa_HashFindFreeKeyBlock()
395 if (_mesa_HashLookup_unlocked(table, key)) { in _mesa_HashFindFreeKeyBlock()
415 * Return the number of entries in the hash table.
418 _mesa_HashNumEntries(const struct _mesa_HashTable *table) in _mesa_HashNumEntries() argument
422 if (table->deleted_key_data) in _mesa_HashNumEntries()
425 count += _mesa_hash_table_num_entries(table->ht); in _mesa_HashNumEntries()