Commit ad6bc521bd2748a5f2581edf32b4732a1af7ab4c

Sylvain 2022-04-01T07:59:16

Move SDL_List functions to SDL_list.c to avoid more merge with eventual PR

diff --git a/Makefile.os2 b/Makefile.os2
index eb34494..3282156 100644
--- a/Makefile.os2
+++ b/Makefile.os2
@@ -60,7 +60,7 @@ CFLAGS_DLL+= -DHAVE_LIBUSB_H=1
 # building SDL itself (for DECLSPEC):
 CFLAGS_DLL+= -DBUILD_SDL
 
-SRCS = SDL.c SDL_assert.c SDL_error.c SDL_log.c SDL_dataqueue.c SDL_hints.c
+SRCS = SDL.c SDL_assert.c SDL_error.c SDL_log.c SDL_dataqueue.c SDL_hints.c SDL_list.c
 SRCS+= SDL_getenv.c SDL_iconv.c SDL_malloc.c SDL_qsort.c SDL_stdlib.c SDL_string.c SDL_strtokr.c SDL_crc32.c
 SRCS+= SDL_cpuinfo.c SDL_atomic.c SDL_spinlock.c SDL_thread.c SDL_timer.c
 SRCS+= SDL_rwops.c SDL_power.c
diff --git a/VisualC-WinRT/SDL-UWP.vcxproj b/VisualC-WinRT/SDL-UWP.vcxproj
index e2dc5eb..681f623 100644
--- a/VisualC-WinRT/SDL-UWP.vcxproj
+++ b/VisualC-WinRT/SDL-UWP.vcxproj
@@ -144,6 +144,7 @@
     <ClInclude Include="..\src\SDL_fatal.h" />
     <ClInclude Include="..\src\SDL_hints_c.h" />
     <ClInclude Include="..\src\SDL_internal.h" />
+    <ClInclude Include="..\src\SDL_list.h" />
     <ClInclude Include="..\src\sensor\dummy\SDL_dummysensor.h" />
     <ClInclude Include="..\src\sensor\SDL_sensor_c.h" />
     <ClInclude Include="..\src\sensor\SDL_syssensor.h" />
@@ -295,6 +296,7 @@
     <ClCompile Include="..\src\SDL.c" />
     <ClCompile Include="..\src\SDL_assert.c" />
     <ClCompile Include="..\src\SDL_dataqueue.c" />
+    <ClCompile Include="..\src\SDL_list.c" />
     <ClCompile Include="..\src\SDL_error.c" />
     <ClCompile Include="..\src\SDL_hints.c" />
     <ClCompile Include="..\src\SDL_log.c" />
diff --git a/VisualC-WinRT/SDL-UWP.vcxproj.filters b/VisualC-WinRT/SDL-UWP.vcxproj.filters
index 2742449..b9a9f82 100644
--- a/VisualC-WinRT/SDL-UWP.vcxproj.filters
+++ b/VisualC-WinRT/SDL-UWP.vcxproj.filters
@@ -411,6 +411,9 @@
     <ClInclude Include="..\src\SDL_dataqueue.h">
       <Filter>Source Files</Filter>
     </ClInclude>
+    <ClInclude Include="..\src\SDL_list.h">
+      <Filter>Source Files</Filter>
+    </ClInclude>
     <ClInclude Include="..\src\haptic\windows\SDL_xinputhaptic_c.h">
       <Filter>Source Files</Filter>
     </ClInclude>
@@ -780,6 +783,9 @@
     <ClCompile Include="..\src\SDL_dataqueue.c">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\src\SDL_list.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
     <ClCompile Include="..\src\haptic\windows\SDL_dinputhaptic.c">
       <Filter>Source Files</Filter>
     </ClCompile>
@@ -819,4 +825,4 @@
       <Filter>Source Files</Filter>
     </ClCompile>
   </ItemGroup>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/VisualC/SDL/SDL.vcxproj b/VisualC/SDL/SDL.vcxproj
index 0e9062b..0d1ab30 100644
--- a/VisualC/SDL/SDL.vcxproj
+++ b/VisualC/SDL/SDL.vcxproj
@@ -369,6 +369,7 @@
     <ClInclude Include="..\..\src\SDL_error_c.h" />
     <ClInclude Include="..\..\src\SDL_hints_c.h" />
     <ClInclude Include="..\..\src\SDL_internal.h" />
+    <ClInclude Include="..\..\src\SDL_list.h" />
     <ClInclude Include="..\..\src\sensor\dummy\SDL_dummysensor.h" />
     <ClInclude Include="..\..\src\sensor\SDL_sensor_c.h" />
     <ClInclude Include="..\..\src\sensor\SDL_syssensor.h" />
@@ -543,6 +544,7 @@
     <ClCompile Include="..\..\src\SDL.c" />
     <ClCompile Include="..\..\src\SDL_assert.c" />
     <ClCompile Include="..\..\src\SDL_dataqueue.c" />
+    <ClCompile Include="..\..\src\SDL_list.c" />
     <ClCompile Include="..\..\src\SDL_error.c" />
     <ClCompile Include="..\..\src\SDL_hints.c" />
     <ClCompile Include="..\..\src\SDL_log.c" />
diff --git a/VisualC/SDL/SDL.vcxproj.filters b/VisualC/SDL/SDL.vcxproj.filters
index da002cd..12162e4 100644
--- a/VisualC/SDL/SDL.vcxproj.filters
+++ b/VisualC/SDL/SDL.vcxproj.filters
@@ -401,6 +401,7 @@
     </ClInclude>
     <ClInclude Include="..\..\src\SDL_dataqueue.h" />
     <ClInclude Include="..\..\src\SDL_error_c.h" />
+    <ClInclude Include="..\..\src\SDL_list.h" />
     <ClInclude Include="..\..\include\SDL_metal.h">
       <Filter>API Headers</Filter>
     </ClInclude>
@@ -832,6 +833,7 @@
     <ClCompile Include="..\..\src\SDL_dataqueue.c" />
     <ClCompile Include="..\..\src\SDL_error.c" />
     <ClCompile Include="..\..\src\SDL_hints.c" />
+    <ClCompile Include="..\..\src\SDL_list.c" />
     <ClCompile Include="..\..\src\audio\SDL_audio.c">
       <Filter>audio</Filter>
     </ClCompile>
diff --git a/src/video/SDL_pixels.c b/src/video/SDL_pixels.c
index b76161d..858ccba 100644
--- a/src/video/SDL_pixels.c
+++ b/src/video/SDL_pixels.c
@@ -28,6 +28,7 @@
 #include "SDL_blit.h"
 #include "SDL_pixels_c.h"
 #include "SDL_RLEaccel_c.h"
+#include "../SDL_list.h"
 
 
 /* Lookup tables to expand partial bytes to the full 0..255 range */
@@ -1024,12 +1025,6 @@ SDL_AllocBlitMap(void)
 }
 
 
-typedef struct SDL_ListNode
-{
-    void *entry;
-    struct SDL_ListNode *next;
-} SDL_ListNode;
-
 void
 SDL_InvalidateAllBlitMap(SDL_Surface *surface)
 {
@@ -1045,40 +1040,6 @@ SDL_InvalidateAllBlitMap(SDL_Surface *surface)
     }
 }
 
-static void SDL_ListAdd(SDL_ListNode **head, void *ent);
-static void SDL_ListRemove(SDL_ListNode **head, void *ent);
-
-void
-SDL_ListAdd(SDL_ListNode **head, void *ent)
-{
-    SDL_ListNode *node = SDL_malloc(sizeof (*node));
-
-    if (node == NULL) {
-        SDL_OutOfMemory();
-        return;
-    }
-
-    node->entry = ent;
-    node->next = *head;
-    *head = node;
-}
-
-void
-SDL_ListRemove(SDL_ListNode **head, void *ent)
-{
-    SDL_ListNode **ptr = head;
-
-    while (*ptr) {
-        if ((*ptr)->entry == ent) {
-            SDL_ListNode *tmp = *ptr;
-            *ptr = (*ptr)->next;
-            SDL_free(tmp);
-            return;
-        }
-        ptr = &(*ptr)->next;
-    }
-}
-
 void
 SDL_InvalidateMap(SDL_BlitMap * map)
 {