Revert "gallium: add util_hash_table_u64"

This reverts commit 2bda62604f.

Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
macos/master
Chia-I Wu 3 years ago
parent 8c6198b41f
commit 59c145a094
  1. 95
      src/gallium/auxiliary/util/u_hash_table.c
  2. 21
      src/gallium/auxiliary/util/u_hash_table.h

@ -47,8 +47,6 @@
#include "util/u_pointer.h"
#include "util/u_hash_table.h"
#define XXH_INLINE_ALL
#include "xxhash.h"
struct util_hash_table
{
@ -300,96 +298,3 @@ util_hash_table_destroy(struct util_hash_table *ht)
FREE(ht);
}
static unsigned hash_func_u64(void *key)
{
return XXH32(key, sizeof(uint64_t), 0);
}
static int compare_func_u64(void *key1, void *key2)
{
return *(const uint64_t *)key1 != *(const uint64_t*)key2;
}
struct util_hash_table_u64 *
util_hash_table_create_u64(void (*destroy)(void *value))
{
return (struct util_hash_table_u64 *)
util_hash_table_create(hash_func_u64,
compare_func_u64,
destroy);
}
enum pipe_error
util_hash_table_set_u64(struct util_hash_table_u64 *ht_u64,
uint64_t key,
void *value)
{
struct util_hash_table *ht = (struct util_hash_table *)ht_u64;
uint64_t *real_key;
enum pipe_error err;
real_key = MALLOC(sizeof(*real_key));
if (!real_key)
return PIPE_ERROR_OUT_OF_MEMORY;
*real_key = key;
err = util_hash_table_set(ht, real_key, value);
if (err != PIPE_OK)
FREE(real_key);
return err;
}
void *
util_hash_table_get_u64(struct util_hash_table_u64 *ht_u64,
uint64_t key)
{
struct util_hash_table *ht = (struct util_hash_table *)ht_u64;
return util_hash_table_get(ht, &key);
}
void
util_hash_table_remove_u64(struct util_hash_table_u64 *ht_u64,
uint64_t key)
{
struct util_hash_table *ht = (struct util_hash_table *)ht_u64;
unsigned key_hash;
struct cso_hash_iter iter;
struct util_hash_table_item *item;
key_hash = ht->hash(&key);
iter = util_hash_table_find_iter(ht, &key, key_hash);
if (cso_hash_iter_is_null(iter))
return;
item = util_hash_table_item(iter);
ht->destroy(item->value);
FREE(item->key);
FREE(item);
cso_hash_erase(ht->cso, iter);
}
void
util_hash_table_destroy_u64(struct util_hash_table_u64 *ht_u64)
{
struct util_hash_table *ht = (struct util_hash_table *)ht_u64;
struct cso_hash_iter iter;
struct util_hash_table_item *item;
iter = cso_hash_first_node(ht->cso);
while (!cso_hash_iter_is_null(iter)) {
item = util_hash_table_item(iter);
ht->destroy(item->value);
FREE(item->key);
FREE(item);
iter = cso_hash_iter_next(iter);
}
cso_hash_delete(ht->cso);
FREE(ht);
}

@ -47,7 +47,6 @@ extern "C" {
* Generic purpose hash table.
*/
struct util_hash_table;
struct util_hash_table_u64;
/**
@ -91,26 +90,6 @@ void
util_hash_table_destroy(struct util_hash_table *ht);
struct util_hash_table_u64 *
util_hash_table_create_u64(void (*destroy)(void *value));
enum pipe_error
util_hash_table_set_u64(struct util_hash_table_u64 *ht,
uint64_t key,
void *value);
void *
util_hash_table_get_u64(struct util_hash_table_u64 *ht,
uint64_t key);
void
util_hash_table_remove_u64(struct util_hash_table_u64 *ht,
uint64_t key);
void
util_hash_table_destroy_u64(struct util_hash_table_u64 *ht);
#ifdef __cplusplus
}
#endif

Loading…
Cancel
Save