#include "hash_table.h"
+#define SIZE 1000
+
static void *make_key(uint32_t i)
{
return (void *)(uintptr_t)(1 + i);
int main()
{
struct hash_table *ht;
- const uint32_t size = 1000;
- bool flags[size];
+ bool flags[SIZE];
uint32_t i;
ht = _mesa_hash_table_create(NULL, key_hash, key_equal);
- for (i = 0; i < size; ++i) {
+ for (i = 0; i < SIZE; ++i) {
flags[i] = false;
_mesa_hash_table_insert(ht, make_key(i), &flags[i]);
}
/* Check that delete_function was called and that repopulating the table
* works. */
- for (i = 0; i < size; ++i) {
+ for (i = 0; i < SIZE; ++i) {
assert(flags[i]);
flags[i] = false;
_mesa_hash_table_insert(ht, make_key(i), &flags[i]);
}
/* Check that exactly the right set of entries is in the table. */
- for (i = 0; i < size; ++i) {
+ for (i = 0; i < SIZE; ++i) {
assert(_mesa_hash_table_search(ht, make_key(i)));
}
hash_table_foreach(ht, entry) {
- assert(key_id(entry->key) < size);
+ assert(key_id(entry->key) < SIZE);
}
_mesa_hash_table_destroy(ht, NULL);
#include <assert.h>
#include "hash_table.h"
+#define SIZE 10000
+
static uint32_t
key_value(const void *key)
{
{
struct hash_table *ht;
struct hash_entry *entry;
- unsigned size = 10000;
- uint32_t keys[size];
+ uint32_t keys[SIZE];
uint32_t i;
(void) argc;
ht = _mesa_hash_table_create(NULL, key_value, uint32_t_key_equals);
- for (i = 0; i < size; i++) {
+ for (i = 0; i < SIZE; i++) {
keys[i] = i;
_mesa_hash_table_insert(ht, keys + i, NULL);
}
/* Make sure that all our entries were present at the end. */
- for (i = size - 100; i < size; i++) {
+ for (i = SIZE - 100; i < SIZE; i++) {
entry = _mesa_hash_table_search(ht, keys + i);
assert(entry);
assert(key_value(entry->key) == i);
for (entry = _mesa_hash_table_next_entry(ht, NULL);
entry != NULL;
entry = _mesa_hash_table_next_entry(ht, entry)) {
- assert(key_value(entry->key) >= size - 100 &&
- key_value(entry->key) < size);
+ assert(key_value(entry->key) >= SIZE - 100 &&
+ key_value(entry->key) < SIZE);
}
assert(ht->entries == 100);
#include <assert.h>
#include "hash_table.h"
+#define SIZE 10000
+
static uint32_t
key_value(const void *key)
{
{
struct hash_table *ht;
struct hash_entry *entry;
- unsigned size = 10000;
- uint32_t keys[size];
+ uint32_t keys[SIZE];
uint32_t i;
(void) argc;
ht = _mesa_hash_table_create(NULL, key_value, uint32_t_key_equals);
- for (i = 0; i < size; i++) {
+ for (i = 0; i < SIZE; i++) {
keys[i] = i;
_mesa_hash_table_insert(ht, keys + i, NULL);
}
- for (i = 0; i < size; i++) {
+ for (i = 0; i < SIZE; i++) {
entry = _mesa_hash_table_search(ht, keys + i);
assert(entry);
assert(key_value(entry->key) == i);
}
- assert(ht->entries == size);
+ assert(ht->entries == SIZE);
_mesa_hash_table_destroy(ht, NULL);
executable(
'@0@_test'.format(t),
files('@0@.c'.format(t)),
+ c_args : [c_msvc_compat_args],
dependencies : [dep_thread, dep_dl],
include_directories : [inc_include, inc_util],
link_with : libmesa_util,
#include <assert.h>
#include "hash_table.h"
+#define SIZE 10000
+
static uint32_t
key_value(const void *key)
{
{
struct hash_table *ht;
struct hash_entry *entry;
- unsigned size = 10000;
- uint32_t keys[size];
+ uint32_t keys[SIZE];
uint32_t i, random_value;
(void) argc;
ht = _mesa_hash_table_create(NULL, key_value, uint32_t_key_equals);
- for (i = 0; i < size; i++) {
+ for (i = 0; i < SIZE; i++) {
keys[i] = i;
_mesa_hash_table_insert(ht, keys + i, NULL);