SDL: Updated SDL_TLSID to use the same type as other IDs in SDL

From df4b855af5d918b1f565795412b6391df4511857 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 18 Jan 2024 05:30:51 -0800
Subject: [PATCH] Updated SDL_TLSID to use the same type as other IDs in SDL

---
 include/SDL3/SDL_thread.h | 2 +-
 src/thread/SDL_thread.c   | 3 ++-
 src/thread/SDL_thread_c.h | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/include/SDL3/SDL_thread.h b/include/SDL3/SDL_thread.h
index 9f10ec0a5045..bf3e33aaf283 100644
--- a/include/SDL3/SDL_thread.h
+++ b/include/SDL3/SDL_thread.h
@@ -53,7 +53,7 @@ typedef struct SDL_Thread SDL_Thread;
 typedef Uint64 SDL_ThreadID;
 
 /* Thread local storage ID, 0 is the invalid ID */
-typedef unsigned int SDL_TLSID;
+typedef Uint32 SDL_TLSID;
 
 /**
  *  The SDL thread priority.
diff --git a/src/thread/SDL_thread.c b/src/thread/SDL_thread.c
index 6468387e884b..3b6bb9b83590 100644
--- a/src/thread/SDL_thread.c
+++ b/src/thread/SDL_thread.c
@@ -29,7 +29,7 @@
 SDL_TLSID SDL_CreateTLS(void)
 {
     static SDL_AtomicInt SDL_tls_id;
-    return SDL_AtomicIncRef(&SDL_tls_id) + 1;
+    return (SDL_TLSID)(SDL_AtomicIncRef(&SDL_tls_id) + 1);
 }
 
 void *SDL_GetTLS(SDL_TLSID id)
@@ -60,6 +60,7 @@ int SDL_SetTLS(SDL_TLSID id, const void *value, void(SDLCALL *destructor)(void *
         newlimit = (id + TLS_ALLOC_CHUNKSIZE);
         new_storage = (SDL_TLSData *)SDL_realloc(storage, sizeof(*storage) + (newlimit - 1) * sizeof(storage->array[0]));
         if (!new_storage) {
+            SDL_OutOfMemory();
             return -1;
         }
         storage = new_storage;
diff --git a/src/thread/SDL_thread_c.h b/src/thread/SDL_thread_c.h
index 6f88a9572db5..42737a59e9ce 100644
--- a/src/thread/SDL_thread_c.h
+++ b/src/thread/SDL_thread_c.h
@@ -78,7 +78,7 @@ extern void SDL_RunThread(SDL_Thread *thread);
 /* This is the system-independent thread local storage structure */
 typedef struct
 {
-    unsigned int limit;
+    SDL_TLSID limit;
     struct
     {
         void *data;