/** * Test walking over all the entries in a hash table. */ static void test_hash_walking(void) { struct _mesa_HashTable *t = _mesa_NewHashTable(); const GLuint limit = 50000; GLuint i; /* create some entries */ for (i = 0; i < limit; i++) { GLuint dummy; GLuint k = (rand() % (limit * 10)) + 1; while (_mesa_HashLookup(t, k)) { /* id already in use, try another */ k = (rand() % (limit * 10)) + 1; } _mesa_HashInsert(t, k, &dummy); } /* walk over all entries */ { GLuint k = _mesa_HashFirstEntry(t); GLuint count = 0; while (k) { GLuint knext = _mesa_HashNextEntry(t, k); assert(knext != k); _mesa_HashRemove(t, k); count++; k = knext; } assert(count == limit); k = _mesa_HashFirstEntry(t); assert(k==0); } _mesa_DeleteHashTable(t); }
/** * Free the context state related to query objects. */ void _mesa_free_query_data(GLcontext *ctx) { while (1) { GLuint id = _mesa_HashFirstEntry(ctx->Query.QueryObjects); if (id) { struct gl_query_object *q = lookup_query_object(ctx, id); ASSERT(q); delete_query_object(q); _mesa_HashRemove(ctx->Query.QueryObjects, id); } else { break; } } _mesa_DeleteHashTable(ctx->Query.QueryObjects); }