Added SDL_HashPointer() and SDL_KeyMatchPointer()

This commit is contained in:
Sam Lantinga
2024-09-29 10:58:54 -07:00
parent d0c9c008e1
commit c84d825241
2 changed files with 14 additions and 4 deletions

View File

@@ -493,6 +493,16 @@ static SDL_INLINE Uint32 hash_string_djbxor(const char *str, size_t len)
return hash; return hash;
} }
Uint32 SDL_HashPointer(const void *key, void *unused)
{
return SDL_murmur3_32(&key, sizeof(key), 0);
}
bool SDL_KeyMatchPointer(const void *a, const void *b, void *unused)
{
return (a == b);
}
Uint32 SDL_HashString(const void *key, void *data) Uint32 SDL_HashString(const void *key, void *data)
{ {
const char *str = (const char *)key; const char *str = (const char *)key;
@@ -524,10 +534,7 @@ Uint32 SDL_HashID(const void *key, void *unused)
bool SDL_KeyMatchID(const void *a, const void *b, void *unused) bool SDL_KeyMatchID(const void *a, const void *b, void *unused)
{ {
if (a == b) { return (a == b);
return true;
}
return false;
} }
void SDL_NukeFreeKey(const void *key, const void *value, void *unused) void SDL_NukeFreeKey(const void *key, const void *value, void *unused)

View File

@@ -49,6 +49,9 @@ extern bool SDL_IterateHashTableKey(const SDL_HashTable *table, const void *key,
// iterate all key/value pairs in a hash (stackable hashes can have duplicate keys with multiple values). // iterate all key/value pairs in a hash (stackable hashes can have duplicate keys with multiple values).
extern bool SDL_IterateHashTable(const SDL_HashTable *table, const void **_key, const void **_value, void **iter); extern bool SDL_IterateHashTable(const SDL_HashTable *table, const void **_key, const void **_value, void **iter);
extern Uint32 SDL_HashPointer(const void *key, void *unused);
extern bool SDL_KeyMatchPointer(const void *a, const void *b, void *unused);
extern Uint32 SDL_HashString(const void *key, void *unused); extern Uint32 SDL_HashString(const void *key, void *unused);
extern bool SDL_KeyMatchString(const void *a, const void *b, void *unused); extern bool SDL_KeyMatchString(const void *a, const void *b, void *unused);