Removed external hashtable locking functions

Read-write locks are not recursive and can't be upgraded from one type to another, so it's not safe to lock the hash table and then call functions that operate on it. If you really want this functionality, we'd need to create unlocked versions of the hashtable functions and you would call those once you've taken a lock on the hashtable, and we'd have to assert that the operations you're doing are compatible with the type of lock you've taken.

All of that complicates working with hashtables, so if you need that type of access, you should probably just use external locking.
This commit is contained in:
Sam Lantinga
2024-12-12 13:15:05 -08:00
parent 61511c48a4
commit 43a61fec91
4 changed files with 71 additions and 56 deletions

View File

@@ -493,28 +493,6 @@ bool SDL_HashTableEmpty(SDL_HashTable *table)
return !(table && table->num_occupied_slots);
}
void SDL_LockHashTable(SDL_HashTable *table, bool for_writing)
{
if (!table) {
return;
}
if (for_writing) {
SDL_LockRWLockForWriting(table->lock);
} else {
SDL_LockRWLockForReading(table->lock);
}
}
void SDL_UnlockHashTable(SDL_HashTable *table)
{
if (!table) {
return;
}
SDL_UnlockRWLock(table->lock);
}
static void nuke_all(SDL_HashTable *table)
{
void *data = table->data;