mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 00:10:10 +01:00
prog_hash_table: Convert compare funcs to match util/hash_table.h.
I'm going to replace this hash table with util/hash_table.h, and the first step is to compare things the same way. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
This commit is contained in:
parent
60f1b436b9
commit
91945f9e91
2 changed files with 11 additions and 7 deletions
|
|
@ -47,7 +47,7 @@ extern "C" {
|
||||||
struct hash_table;
|
struct hash_table;
|
||||||
|
|
||||||
typedef unsigned (*hash_func_t)(const void *key);
|
typedef unsigned (*hash_func_t)(const void *key);
|
||||||
typedef int (*hash_compare_func_t)(const void *key1, const void *key2);
|
typedef bool (*hash_compare_func_t)(const void *key1, const void *key2);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hash table constructor
|
* Hash table constructor
|
||||||
|
|
@ -151,12 +151,11 @@ extern unsigned hash_table_string_hash(const void *key);
|
||||||
/**
|
/**
|
||||||
* Compare two strings used as keys
|
* Compare two strings used as keys
|
||||||
*
|
*
|
||||||
* This is just a macro wrapper around \c strcmp.
|
* This is just a wrapper around \c strcmp.
|
||||||
*
|
*
|
||||||
* \sa hash_table_string_hash
|
* \sa hash_table_string_hash
|
||||||
*/
|
*/
|
||||||
#define hash_table_string_compare ((hash_compare_func_t) strcmp)
|
bool hash_table_string_compare(const void *a, const void *b);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute hash value of a pointer
|
* Compute hash value of a pointer
|
||||||
|
|
@ -178,7 +177,7 @@ hash_table_pointer_hash(const void *key);
|
||||||
*
|
*
|
||||||
* \sa hash_table_pointer_hash
|
* \sa hash_table_pointer_hash
|
||||||
*/
|
*/
|
||||||
int
|
bool
|
||||||
hash_table_pointer_compare(const void *key1, const void *key2);
|
hash_table_pointer_compare(const void *key1, const void *key2);
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -228,6 +228,11 @@ hash_table_string_hash(const void *key)
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hash_table_string_compare(const void *a, const void *b)
|
||||||
|
{
|
||||||
|
return strcmp(a, b) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned
|
unsigned
|
||||||
hash_table_pointer_hash(const void *key)
|
hash_table_pointer_hash(const void *key)
|
||||||
|
|
@ -236,8 +241,8 @@ hash_table_pointer_hash(const void *key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
bool
|
||||||
hash_table_pointer_compare(const void *key1, const void *key2)
|
hash_table_pointer_compare(const void *key1, const void *key2)
|
||||||
{
|
{
|
||||||
return key1 == key2 ? 0 : 1;
|
return key1 == key2;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue