SDL: rwops: Renamed SDL_CreateRW and SDL_DestroyRW to SDL_OpenRW and SDL_CloseRW.

From 655ceb3b315b8eac2940f9f4a183158bb810cb83 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Tue, 12 Mar 2024 09:01:37 -0400
Subject: [PATCH] rwops: Renamed SDL_CreateRW and SDL_DestroyRW to SDL_OpenRW
 and SDL_CloseRW.

---
 build-scripts/SDL_migration.cocci | 10 --------
 docs/README-migration.md          | 10 ++++----
 include/SDL3/SDL_audio.h          |  2 +-
 include/SDL3/SDL_gamepad.h        |  2 +-
 include/SDL3/SDL_oldnames.h       |  4 ---
 include/SDL3/SDL_rwops.h          | 16 ++++++------
 include/SDL3/SDL_surface.h        |  4 +--
 src/audio/SDL_wave.c              |  8 +++---
 src/audio/disk/SDL_diskaudio.c    |  4 +--
 src/dynapi/SDL_dynapi.sym         |  4 +--
 src/dynapi/SDL_dynapi_overrides.h |  4 +--
 src/dynapi/SDL_dynapi_procs.h     |  4 +--
 src/file/SDL_rwops.c              | 20 +++++++--------
 src/test/SDL_test_common.c        |  4 +--
 src/video/SDL_bmp.c               |  4 +--
 test/testautomation_rwops.c       | 42 +++++++++++++++----------------
 test/testfile.c                   | 20 +++++++--------
 test/testime.c                    |  2 +-
 test/testoverlay.c                |  2 +-
 test/testresample.c               |  6 ++---
 test/teststreaming.c              |  2 +-
 test/testutils.c                  |  2 +-
 22 files changed, 81 insertions(+), 95 deletions(-)

diff --git a/build-scripts/SDL_migration.cocci b/build-scripts/SDL_migration.cocci
index b1c411b91f758..5ce27a86e1e2e 100644
--- a/build-scripts/SDL_migration.cocci
+++ b/build-scripts/SDL_migration.cocci
@@ -1815,16 +1815,6 @@ expression e2;
 + SDL_RW_SEEK_SET
 @@
 @@
-- SDL_AllocRW
-+ SDL_CreateRW
-  (...)
-@@
-@@
-- SDL_FreeRW
-+ SDL_DestroyRW
-  (...)
-@@
-@@
 - SDL_SensorClose
 + SDL_CloseSensor
   (...)
diff --git a/docs/README-migration.md b/docs/README-migration.md
index 59e1de2e4bf5f..b16a41a7c9d51 100644
--- a/docs/README-migration.md
+++ b/docs/README-migration.md
@@ -1156,9 +1156,9 @@ The following symbols have been renamed:
 * RW_SEEK_END => SDL_RW_SEEK_END
 * RW_SEEK_SET => SDL_RW_SEEK_SET
 
-SDL_RWops is now an opaque structure. The existing APIs to create a RWops (SDL_RWFromFile, etc) still function as expected, but to make a custom RWops with app-provided function pointers, call SDL_CreateRW and provide the function pointers through there. To call into a RWops's functionality, use the standard APIs (SDL_RWread, etc) instead of calling into function pointers directly.
+SDL_RWops is now an opaque structure. The existing APIs to create a RWops (SDL_RWFromFile, etc) still function as expected, but to make a custom RWops with app-provided function pointers, call SDL_OpenRW and provide the function pointers through there. To call into a RWops's functionality, use the standard APIs (SDL_RWread, etc) instead of calling into function pointers directly.
 
-The RWops function pointers are now in a separate structure called SDL_RWopsInteface, which is provided to SDL_CreateRW. All the functions now take a `void *` userdata argument for their first parameter instead of an SDL_RWops, since that's now an opaque structure.
+The RWops function pointers are now in a separate structure called SDL_RWopsInteface, which is provided to SDL_OpenRW. All the functions now take a `void *` userdata argument for their first parameter instead of an SDL_RWops, since that's now an opaque structure.
 
 SDL_RWread and SDL_RWwrite (and SDL_RWopsInterface::read, SDL_RWopsInterface::write) have a different function signature in SDL3.
 
@@ -1196,11 +1196,11 @@ size_t custom_read(void *ptr, size_t size, size_t nitems, SDL_RWops *stream)
 
 SDL_RWops::type was removed and has no replacement; it wasn't meaningful for app-provided implementations at all, and wasn't much use for SDL's internal implementations, either.
 
-SDL_RWopsInterface::close implementations should clean up their own userdata, but not call SDL_DestroyRW on themselves; now the contract is always that SDL_DestroyRW is called, which calls `->close` and then frees the opaque object.
+SDL_RWopsInterface::close implementations should clean up their own userdata, but not call SDL_CloseRW on themselves; now the contract is always that SDL_CloseRW is called, which calls `->close` and then frees the opaque object.
 
 SDL_RWFromFP has been removed from the API, due to issues when the SDL library uses a different C runtime from the application.
 
-SDL_AllocRW(), SDL_FreeRW(), SDL_RWclose() and direct access to the `->close` function pointer have been removed from the API, so there's only one path to manage RWops lifetimes now: SDL_CreateRW() and SDL_DestroyRW().
+SDL_AllocRW(), SDL_FreeRW(), SDL_RWclose() and direct access to the `->close` function pointer have been removed from the API, so there's only one path to manage RWops lifetimes now: SDL_OpenRW() and SDL_CloseRW().
 
 
 You can implement this in your own code easily:
@@ -1295,7 +1295,7 @@ SDL_RWops *SDL_RWFromFP(FILE *fp, SDL_bool autoclose)
     rwopsdata->fp = fp;
     rwopsdata->autoclose = autoclose;
 
-    rwops = SDL_CreateRW(&iface, rwopsdata);
+    rwops = SDL_OpenRW(&iface, rwopsdata);
     if (!rwops) {
         iface.close(rwopsdata);
     }
diff --git a/include/SDL3/SDL_audio.h b/include/SDL3/SDL_audio.h
index 60eb3e7dcf130..281af06b04db7 100644
--- a/include/SDL3/SDL_audio.h
+++ b/include/SDL3/SDL_audio.h
@@ -1317,7 +1317,7 @@ extern DECLSPEC int SDLCALL SDL_SetAudioPostmixCallback(SDL_AudioDeviceID devid,
  * ```
  *
  * \param src The data source for the WAVE data
- * \param freesrc If SDL_TRUE, calls SDL_DestroyRW() on `src` before returning,
+ * \param freesrc If SDL_TRUE, calls SDL_CloseRW() on `src` before returning,
  *                even in the case of an error
  * \param spec A pointer to an SDL_AudioSpec that will be set to the WAVE
  *             data's format details on successful return
diff --git a/include/SDL3/SDL_gamepad.h b/include/SDL3/SDL_gamepad.h
index 68bdaa37a03f8..2a65a30748003 100644
--- a/include/SDL3/SDL_gamepad.h
+++ b/include/SDL3/SDL_gamepad.h
@@ -268,7 +268,7 @@ extern DECLSPEC int SDLCALL SDL_AddGamepadMapping(const char *mapping);
  * constrained environment.
  *
  * \param src the data stream for the mappings to be added
- * \param freesrc if SDL_TRUE, calls SDL_DestroyRW() on `src` before returning,
+ * \param freesrc if SDL_TRUE, calls SDL_CloseRW() on `src` before returning,
  *                even in the case of an error
  * \returns the number of mappings added or -1 on error; call SDL_GetError()
  *          for more information.
diff --git a/include/SDL3/SDL_oldnames.h b/include/SDL3/SDL_oldnames.h
index 8ca7dddd029a8..1b2be561154aa 100644
--- a/include/SDL3/SDL_oldnames.h
+++ b/include/SDL3/SDL_oldnames.h
@@ -452,8 +452,6 @@
 #define RW_SEEK_CUR SDL_RW_SEEK_CUR
 #define RW_SEEK_END SDL_RW_SEEK_END
 #define RW_SEEK_SET SDL_RW_SEEK_SET
-#define SDL_AllocRW SDL_CreateRW
-#define SDL_FreeRW SDL_DestroyRW
 #define SDL_ReadBE16 SDL_ReadU16BE
 #define SDL_ReadBE32 SDL_ReadU32BE
 #define SDL_ReadBE64 SDL_ReadU64BE
@@ -938,8 +936,6 @@
 #define RW_SEEK_CUR RW_SEEK_CUR_renamed_SDL_RW_SEEK_CUR
 #define RW_SEEK_END RW_SEEK_END_renamed_SDL_RW_SEEK_END
 #define RW_SEEK_SET RW_SEEK_SET_renamed_SDL_RW_SEEK_SET
-#define SDL_AllocRW SDL_AllocRW_renamed_SDL_CreateRW
-#define SDL_FreeRW SDL_FreeRW_renamed_SDL_DestroyRW
 #define SDL_ReadBE16 SDL_ReadBE16_renamed_SDL_ReadU16BE
 #define SDL_ReadBE32 SDL_ReadBE32_renamed_SDL_ReadU32BE
 #define SDL_ReadBE64 SDL_ReadBE64_renamed_SDL_ReadU64BE
diff --git a/include/SDL3/SDL_rwops.h b/include/SDL3/SDL_rwops.h
index 8fef464ff9218..035886e8c49b4 100644
--- a/include/SDL3/SDL_rwops.h
+++ b/include/SDL3/SDL_rwops.h
@@ -234,30 +234,30 @@ extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromConstMem(const void *mem, size_t si
 
 
 /**
- * Use this function to allocate a SDL_RWops structure.
+ * Create a custom SDL_RWops.
  *
  * Applications do not need to use this function unless they are providing
  * their own SDL_RWops implementation. If you just need an SDL_RWops to
  * read/write a common data source, you should use the built-in
  * implementations in SDL, like SDL_RWFromFile() or SDL_RWFromMem(), etc.
  *
- * You must free the returned pointer with SDL_DestroyRW().
+ * You must free the returned pointer with SDL_CloseRW().
  *
  * \returns a pointer to the allocated memory on success, or NULL on failure;
  *          call SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  *
- * \sa SDL_DestroyRW
+ * \sa SDL_CloseRW
  */
-extern DECLSPEC SDL_RWops *SDLCALL SDL_CreateRW(const SDL_RWopsInterface *iface, void *userdata);
+extern DECLSPEC SDL_RWops *SDLCALL SDL_OpenRW(const SDL_RWopsInterface *iface, void *userdata);
 
 /**
  * Close and free an allocated SDL_RWops structure.
  *
- * SDL_DestroyRW() closes and cleans up the SDL_RWops stream. It releases any
+ * SDL_CloseRW() closes and cleans up the SDL_RWops stream. It releases any
  * resources used by the stream and frees the SDL_RWops itself with
- * SDL_DestroyRW(). This returns 0 on success, or -1 if the stream failed to
+ * SDL_CloseRW(). This returns 0 on success, or -1 if the stream failed to
  * flush to its output (e.g. to disk).
  *
  * Note that if this fails to flush the stream to disk, this function reports
@@ -276,7 +276,7 @@ extern DECLSPEC SDL_RWops *SDLCALL SDL_CreateRW(const SDL_RWopsInterface *iface,
  * \sa SDL_RWseek
  * \sa SDL_RWwrite
  */
-extern DECLSPEC int SDLCALL SDL_DestroyRW(SDL_RWops *context);
+extern DECLSPEC int SDLCALL SDL_CloseRW(SDL_RWops *context);
 
 /**
  * Get the properties associated with an SDL_RWops.
@@ -489,7 +489,7 @@ extern DECLSPEC size_t SDLCALL SDL_RWvprintf(SDL_RWops *context, SDL_PRINTF_FORM
  *
  * \param src the SDL_RWops to read all available data from
  * \param datasize if not NULL, will store the number of bytes read
- * \param freesrc if SDL_TRUE, calls SDL_DestroyRW() on `src` before returning,
+ * \param freesrc if SDL_TRUE, calls SDL_CloseRW() on `src` before returning,
  *                even in the case of an error
  * \returns the data, or NULL if there was an error.
  *
diff --git a/include/SDL3/SDL_surface.h b/include/SDL3/SDL_surface.h
index 63300b70c29aa..11903fae14c44 100644
--- a/include/SDL3/SDL_surface.h
+++ b/include/SDL3/SDL_surface.h
@@ -328,7 +328,7 @@ extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface *surface);
  * will result in a memory leak.
  *
  * \param src the data stream for the surface
- * \param freesrc if SDL_TRUE, calls SDL_DestroyRW() on `src` before returning,
+ * \param freesrc if SDL_TRUE, calls SDL_CloseRW() on `src` before returning,
  *                even in the case of an error
  * \returns a pointer to a new SDL_Surface structure or NULL if there was an
  *          error; call SDL_GetError() for more information.
@@ -370,7 +370,7 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP(const char *file);
  *
  * \param surface the SDL_Surface structure containing the image to be saved
  * \param dst a data stream to save to
- * \param freedst if SDL_TRUE, calls SDL_DestroyRW() on `dst` before returning,
+ * \param freedst if SDL_TRUE, calls SDL_CloseRW() on `dst` before returning,
  *                even in the case of an error
  * \returns 0 on success or a negative error code on failure; call
  *          SDL_GetError() for more information.
diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c
index 755e49b1b19d6..29f0cfb33d917 100644
--- a/src/audio/SDL_wave.c
+++ b/src/audio/SDL_wave.c
@@ -1629,7 +1629,7 @@ static int WaveReadFormat(WaveFile *file)
             return -1;
         }
     } else if (format->encoding == PCM_CODE) {
-        SDL_DestroyRW(fmtsrc);
+        SDL_CloseRW(fmtsrc);
         return SDL_SetError("Missing wBitsPerSample field in WAVE fmt chunk");
     }
 
@@ -1649,7 +1649,7 @@ static int WaveReadFormat(WaveFile *file)
 
         /* Extensible header must be at least 22 bytes. */
         if (fmtlen < 40 || format->extsize < 22) {
-            SDL_DestroyRW(fmtsrc);
+            SDL_CloseRW(fmtsrc);
             return SDL_SetError("Extensible WAVE header too small");
         }
 
@@ -1661,7 +1661,7 @@ static int WaveReadFormat(WaveFile *file)
         format->encoding = WaveGetFormatGUIDEncoding(format);
     }
 
-    SDL_DestroyRW(fmtsrc);
+    SDL_CloseRW(fmtsrc);
 
     return 0;
 }
@@ -2117,7 +2117,7 @@ int SDL_LoadWAV_RW(SDL_RWops *src, SDL_bool freesrc, SDL_AudioSpec *spec, Uint8
     SDL_free(file.decoderdata);
 done:
     if (freesrc && src) {
-        SDL_DestroyRW(src);
+        SDL_CloseRW(src);
     }
     return result;
 }
diff --git a/src/audio/disk/SDL_diskaudio.c b/src/audio/disk/SDL_diskaudio.c
index 9c2e5651c0421..cbd86180a1cd7 100644
--- a/src/audio/disk/SDL_diskaudio.c
+++ b/src/audio/disk/SDL_diskaudio.c
@@ -68,7 +68,7 @@ static int DISKAUDIO_CaptureFromDevice(SDL_AudioDevice *device, void *buffer, in
         buflen -= br;
         buffer = ((Uint8 *)buffer) + br;
         if (buflen > 0) { // EOF (or error, but whatever).
-            SDL_DestroyRW(h->io);
+            SDL_CloseRW(h->io);
             h->io = NULL;
         }
     }
@@ -88,7 +88,7 @@ static void DISKAUDIO_CloseDevice(SDL_AudioDevice *device)
 {
     if (device->hidden) {
         if (device->hidden->io) {
-            SDL_DestroyRW(device->hidden->io);
+            SDL_CloseRW(device->hidden->io);
         }
         SDL_free(device->hidden->mixbuf);
         SDL_free(device->hidden);
diff --git a/src/dynapi/SDL_dynapi.sym b/src/dynapi/SDL_dynapi.sym
index 00c0d7abc0ced..ae0f3fa573bf9 100644
--- a/src/dynapi/SDL_dynapi.sym
+++ b/src/dynapi/SDL_dynapi.sym
@@ -52,7 +52,6 @@ SDL3_0.0.0 {
     SDL_CreatePalette;
     SDL_CreatePixelFormat;
     SDL_CreatePopupWindow;
-    SDL_CreateRW;
     SDL_CreateRWLock;
     SDL_CreateRenderer;
     SDL_CreateSemaphore;
@@ -79,7 +78,6 @@ SDL3_0.0.0 {
     SDL_DestroyMutex;
     SDL_DestroyPalette;
     SDL_DestroyPixelFormat;
-    SDL_DestroyRW;
     SDL_DestroyRWLock;
     SDL_DestroyRenderer;
     SDL_DestroySemaphore;
@@ -978,6 +976,8 @@ SDL3_0.0.0 {
     SDL_ShowOpenFileDialog;
     SDL_ShowSaveFileDialog;
     SDL_ShowOpenFolderDialog;
+    SDL_OpenRW;
+    SDL_CloseRW;
     # extra symbols go here (don't modify this line)
   local: *;
 };
diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h
index 75dec01de654b..bb9d3a0e46f6c 100644
--- a/src/dynapi/SDL_dynapi_overrides.h
+++ b/src/dynapi/SDL_dynapi_overrides.h
@@ -76,7 +76,6 @@
 #define SDL_CreatePalette SDL_CreatePalette_REAL
 #define SDL_CreatePixelFormat SDL_CreatePixelFormat_REAL
 #define SDL_CreatePopupWindow SDL_CreatePopupWindow_REAL
-#define SDL_CreateRW SDL_CreateRW_REAL
 #define SDL_CreateRWLock SDL_CreateRWLock_REAL
 #define SDL_CreateRenderer SDL_CreateRenderer_REAL
 #define SDL_CreateSemaphore SDL_CreateSemaphore_REAL
@@ -103,7 +102,6 @@
 #define SDL_DestroyMutex SDL_DestroyMutex_REAL
 #define SDL_DestroyPalette SDL_DestroyPalette_REAL
 #define SDL_DestroyPixelFormat SDL_DestroyPixelFormat_REAL
-#define SDL_DestroyRW SDL_DestroyRW_REAL
 #define SDL_DestroyRWLock SDL_DestroyRWLock_REAL
 #define SDL_DestroyRenderer SDL_DestroyRenderer_REAL
 #define SDL_DestroySemaphore SDL_DestroySemaphore_REAL
@@ -1003,3 +1001,5 @@
 #define SDL_ShowOpenFileDialog SDL_ShowOpenFileDialog_REAL
 #define SDL_ShowSaveFileDialog SDL_ShowSaveFileDialog_REAL
 #define SDL_ShowOpenFolderDialog SDL_ShowOpenFolderDialog_REAL
+#define SDL_OpenRW SDL_OpenRW_REAL
+#define SDL_CloseRW SDL_CloseRW_REAL
diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h
index 8a72f8db673b1..370e9a8321b8c 100644
--- a/src/dynapi/SDL_dynapi_procs.h
+++ b/src/dynapi/SDL_dynapi_procs.h
@@ -142,7 +142,6 @@ SDL_DYNAPI_PROC(SDL_Mutex*,SDL_CreateMutex,(void),(),return)
 SDL_DYNAPI_PROC(SDL_Palette*,SDL_CreatePalette,(int a),(a),return)
 SDL_DYNAPI_PROC(SDL_PixelFormat*,SDL_CreatePixelFormat,(SDL_PixelFormatEnum a),(a),return)
 SDL_DYNAPI_PROC(SDL_Window*,SDL_CreatePopupWindow,(SDL_Window *a, int b, int c, int d, int e, Uint32 f),(a,b,c,d,e,f),return)
-SDL_DYNAPI_PROC(SDL_RWops*,SDL_CreateRW,(const SDL_RWopsInterface *a, void *b),(a,b),return)
 SDL_DYNAPI_PROC(SDL_RWLock*,SDL_CreateRWLock,(void),(),return)
 SDL_DYNAPI_PROC(SDL_Renderer*,SDL_CreateRenderer,(SDL_Window *a, const char *b, Uint32 c),(a,b,c),return)
 SDL_DYNAPI_PROC(SDL_Semaphore*,SDL_CreateSemaphore,(Uint32 a),(a),return)
@@ -166,7 +165,6 @@ SDL_DYNAPI_PROC(void,SDL_DestroyCursor,(SDL_Cursor *a),(a),)
 SDL_DYNAPI_PROC(void,SDL_DestroyMutex,(SDL_Mutex *a),(a),)
 SDL_DYNAPI_PROC(void,SDL_DestroyPalette,(SDL_Palette *a),(a),)
 SDL_DYNAPI_PROC(void,SDL_DestroyPixelFormat,(SDL_PixelFormat *a),(a),)
-SDL_DYNAPI_PROC(int,SDL_DestroyRW,(SDL_RWops *a),(a),return)
 SDL_DYNAPI_PROC(void,SDL_DestroyRWLock,(SDL_RWLock *a),(a),)
 SDL_DYNAPI_PROC(void,SDL_DestroyRenderer,(SDL_Renderer *a),(a),)
 SDL_DYNAPI_PROC(void,SDL_DestroySemaphore,(SDL_Semaphore *a),(a),)
@@ -1028,3 +1026,5 @@ SDL_DYNAPI_PROC(int,SDL_GetJoystickBall,(SDL_Joystick *a, int b, int *c, int *d)
 SDL_DYNAPI_PROC(void,SDL_ShowOpenFileDialog,(SDL_DialogFileCallback a, void *b, SDL_Window *c, const SDL_DialogFileFilter *d, const char *e, int f),(a,b,c,d,e,f),)
 SDL_DYNAPI_PROC(void,SDL_ShowSaveFileDialog,(SDL_DialogFileCallback a, void *b, SDL_Window *c, const SDL_DialogFileFilter *d, const char *e),(a,b,c,d,e),)
 SDL_DYNAPI_PROC(void,SDL_ShowOpenFolderDialog,(SDL_DialogFileCallback a, void *b, SDL_Window *c, const char *d, int e),(a,b,c,d,e),)
+SDL_DYNAPI_PROC(SDL_RWops*,SDL_OpenRW,(const SDL_RWopsInterface *a, void *b),(a,b),return)
+SDL_DYNAPI_PROC(int,SDL_CloseRW,(SDL_RWops *a),(a),return)
diff --git a/src/file/SDL_rwops.c b/src/file/SDL_rwops.c
index 21d0f7efc5b9d..d736b3d83b558 100644
--- a/src/file/SDL_rwops.c
+++ b/src/file/SDL_rwops.c
@@ -424,7 +424,7 @@ static SDL_RWops *SDL_RWFromFP(FILE *fp, SDL_bool autoclose)
     rwopsdata->fp = fp;
     rwopsdata->autoclose = autoclose;
 
-    SDL_RWops *rwops = SDL_CreateRW(&iface, rwopsdata);
+    SDL_RWops *rwops = SDL_OpenRW(&iface, rwopsdata);
     if (!rwops) {
         iface.close(rwopsdata);
     }
@@ -565,7 +565,7 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode)
 
     void *rwopsdata = NULL;
     if (Android_JNI_FileOpen(&rwopsdata, file, mode) < 0) {
-        SDL_DestroyRW(rwops);
+        SDL_CloseRW(rwops);
         return NULL;
     }
 
@@ -577,7 +577,7 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode)
     iface.write = Android_JNI_FileWrite;
     iface.close = Android_JNI_FileClose;
 
-    rwops = SDL_CreateRW(&iface, rwopsdata);
+    rwops = SDL_OpenRW(&iface, rwopsdata);
     if (!rwops) {
         iface.close(rwopsdata);
     }
@@ -591,7 +591,7 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode)
     }
 
     if (windows_file_open(rwopsdata, file, mode) < 0) {
-        SDL_DestroyRW(rwops);
+        SDL_CloseRW(rwops);
         return NULL;
     }
 
@@ -603,7 +603,7 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode)
     iface.write = windows_file_write;
     iface.close = windows_file_close;
 
-    rwops = SDL_CreateRW(&iface, rwopsdata);
+    rwops = SDL_OpenRW(&iface, rwopsdata);
     if (!rwops) {
         windows_file_close(rwopsdata);
     }
@@ -666,7 +666,7 @@ SDL_RWops *SDL_RWFromMem(void *mem, size_t size)
     rwopsdata->here = rwopsdata->base;
     rwopsdata->stop = rwopsdata->base + size;
 
-    SDL_RWops *rwops = SDL_CreateRW(&iface, rwopsdata);
+    SDL_RWops *rwops = SDL_OpenRW(&iface, rwopsdata);
     if (!rwops) {
         SDL_free(rwopsdata);
     }
@@ -699,14 +699,14 @@ SDL_RWops *SDL_RWFromConstMem(const void *mem, size_t size)
     rwopsdata->here = rwopsdata->base;
     rwopsdata->stop = rwopsdata->base + size;
 
-    SDL_RWops *rwops = SDL_CreateRW(&iface, rwopsdata);
+    SDL_RWops *rwops = SDL_OpenRW(&iface, rwopsdata);
     if (!rwops) {
         SDL_free(rwopsdata);
     }
     return rwops;
 }
 
-SDL_RWops *SDL_CreateRW(const SDL_RWopsInterface *iface, void *userdata)
+SDL_RWops *SDL_OpenRW(const SDL_RWopsInterface *iface, void *userdata)
 {
     if (!iface) {
         SDL_InvalidParamError("iface");
@@ -721,7 +721,7 @@ SDL_RWops *SDL_CreateRW(const SDL_RWopsInterface *iface, void *userdata)
     return rwops;
 }
 
-int SDL_DestroyRW(SDL_RWops *rwops)
+int SDL_CloseRW(SDL_RWops *rwops)
 {
     int retval = 0;
     if (rwops) {
@@ -797,7 +797,7 @@ void *SDL_LoadFile_RW(SDL_RWops *src, size_t *datasize, SDL_bool freesrc)
         *datasize = (size_t)size_total;
     }
     if (freesrc && src) {
-        SDL_DestroyRW(src);
+        SDL_CloseRW(src);
     }
     return data;
 }
diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c
index 4a38ad289a12b..1673fb86d3832 100644
--- a/src/test/SDL_test_common.c
+++ b/src/test/SDL_test_common.c
@@ -1913,7 +1913,7 @@ static const void *SDLTest_ScreenShotClipboardProvider(void *context, const char
                     image = NULL;
                 }
             }
-            SDL_DestroyRW(file);
+            SDL_CloseRW(file);
 
             if (image) {
                 data->image = image;
@@ -1984,7 +1984,7 @@ static void SDLTest_PasteScreenShot(void)
             if (file) {
                 SDL_Log("Writing clipboard image to %s", filename);
                 SDL_RWwrite(file, data, size);
-                SDL_DestroyRW(file);
+                SDL_CloseRW(file);
             }
             SDL_free(data);
             return;
diff --git a/src/video/SDL_bmp.c b/src/video/SDL_bmp.c
index 44fd9e1998c8c..9c79092864310 100644
--- a/src/video/SDL_bmp.c
+++ b/src/video/SDL_bmp.c
@@ -578,7 +578,7 @@ SDL_Surface *SDL_LoadBMP_RW(SDL_RWops *src, SDL_bool freesrc)
         surface = NULL;
     }
     if (freesrc && src) {
-        SDL_DestroyRW(src);
+        SDL_CloseRW(src);
     }
     return surface;
 }
@@ -857,7 +857,7 @@ int SDL_SaveBMP_RW(SDL_Surface *surface, SDL_RWops *dst, SDL_bool freedst)
         SDL_DestroySurface(intermediate_surface);
     }
     if (freedst && dst) {
-        if (SDL_DestroyRW(dst) < 0) {
+        if (SDL_CloseRW(dst) < 0) {
             was_error = SDL_TRUE;
         }
     }
diff --git a/test/testautomation_rwops.c b/test/testautomation_rwops.c
index c2c9c4e9155d3..19475c8572352 100644
--- a/test/testautomation_rwops.c
+++ b/test/testautomation_rwops.c
@@ -273,8 +273,8 @@ static int rwops_testMem(void *arg)
     testGenericRWopsValidations(rw, SDL_TRUE);
 
     /* Close */
-    result = SDL_DestroyRW(rw);
-    SDLTest_AssertPass("Call to SDL_DestroyRW() succeeded");
+    result = SDL_CloseRW(rw);
+    SDLTest_AssertPass("Call to SDL_CloseRW() succeeded");
     SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
 
     return TEST_COMPLETED;
@@ -305,8 +305,8 @@ static int rwops_testConstMem(void *arg)
     testGenericRWopsValidations(rw, SDL_FALSE);
 
     /* Close handle */
-    result = SDL_DestroyRW(rw);
-    SDLTest_AssertPass("Call to SDL_DestroyRW() succeeded");
+    result = SDL_CloseRW(rw);
+    SDLTest_AssertPass("Call to SDL_CloseRW() succeeded");
     SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
 
     return TEST_COMPLETED;
@@ -337,8 +337,8 @@ static int rwops_testFileRead(void *arg)
     testGenericRWopsValidations(rw, SDL_FALSE);
 
     /* Close handle */
-    result = SDL_DestroyRW(rw);
-    SDLTest_AssertPass("Call to SDL_DestroyRW() succeeded");
+    result = SDL_CloseRW(rw);
+    SDLTest_AssertPass("Call to SDL_CloseRW() succeeded");
     SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
 
     return TEST_COMPLETED;
@@ -369,8 +369,8 @@ static int rwops_testFileWrite(void *arg)
     testGenericRWopsValidations(rw, SDL_TRUE);
 
     /* Close handle */
-    result = SDL_DestroyRW(rw);
-    SDLTest_AssertPass("Call to SDL_DestroyRW() succeeded");
+    result = SDL_CloseRW(rw);
+    SDLTest_AssertPass("Call to SDL_CloseRW() succeeded");
     SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
 
     return TEST_COMPLETED;
@@ -379,8 +379,8 @@ static int rwops_testFileWrite(void *arg)
 /**
  * Tests alloc and free RW context.
  *
- * \sa SDL_CreateRW
- * \sa SDL_DestroyRW
+ * \sa SDL_OpenRW
+ * \sa SDL_CloseRW
  */
 static int rwops_testAllocFree(void *arg)
 {
@@ -389,16 +389,16 @@ static int rwops_testAllocFree(void *arg)
     SDL_RWops *rw;
 
     SDL_zero(iface);
-    rw = SDL_CreateRW(&iface, NULL);
-    SDLTest_AssertPass("Call to SDL_CreateRW() succeeded");
-    SDLTest_AssertCheck(rw != NULL, "Validate result from SDL_CreateRW() is not NULL");
+    rw = SDL_OpenRW(&iface, NULL);
+    SDLTest_AssertPass("Call to SDL_OpenRW() succeeded");
+    SDLTest_AssertCheck(rw != NULL, "Validate result from SDL_OpenRW() is not NULL");
     if (rw == NULL) {
         return TEST_ABORTED;
     }
 
     /* Free context again */
-    SDL_DestroyRW(rw);
-    SDLTest_AssertPass("Call to SDL_DestroyRW() succeeded");
+    SDL_CloseRW(rw);
+    SDLTest_AssertPass("Call to SDL_CloseRW() succeeded");
 
     return TEST_COMPLETED;
 }
@@ -435,8 +435,8 @@ static int rwops_testCompareRWFromMemWithRWFromFile(void *arg)
         SDLTest_AssertPass("Call to SDL_RWread(mem, size=%d)", size * 6);
         sv_mem = SDL_RWseek(rwops_mem, 0, SEEK_END);
         SDLTest_AssertPass("Call to SDL_RWseek(mem,SEEK_END)");
-        result = SDL_DestroyRW(rwops_mem);
-        SDLTest_AssertPass("Call to SDL_DestroyRW(mem)");
+        result = SDL_CloseRW(rwops_mem);
+        SDLTest_AssertPass("Call to SDL_CloseRW(mem)");
         SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
 
         /* Read/see from file */
@@ -446,8 +446,8 @@ static int rwops_testCompareRWFromMemWithRWFromFile(void *arg)
         SDLTest_AssertPass("Call to SDL_RWread(file, size=%d)", size * 6);
         sv_file = SDL_RWseek(rwops_file, 0, SEEK_END);
         SDLTest_AssertPass("Call to SDL_RWseek(file,SEEK_END)");
-        result = SDL_DestroyRW(rwops_file);
-        SDLTest_AssertPass("Call to SDL_DestroyRW(file)");
+        result = SDL_CloseRW(rwops_file);
+        SDLTest_AssertPass("Call to SDL_CloseRW(file)");
         SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
 
         /* Compare */
@@ -590,8 +590,8 @@ static int rwops_testFileWriteReadEndian(void *arg)
         SDLTest_AssertCheck(LE64test == LE64value, "Validate object read from SDL_ReadU64LE, expected: %" SDL_PRIu64 ", got: %" SDL_PRIu64, LE64value, LE64test);
 
         /* Close handle */
-        cresult = SDL_DestroyRW(rw);
-        SDLTest_AssertPass("Call to SDL_DestroyRW() succeeded");
+        cresult = SDL_CloseRW(rw);
+        SDLTest_AssertPass("Call to SDL_CloseRW() succeeded");
         SDLTest_AssertCheck(cresult == 0, "Verify result value is 0; got: %d", cresult);
     }
 
diff --git a/test/testfile.c b/test/testfile.c
index aa041ccc058e0..760b31c4a2a69 100644
--- a/test/testfile.c
+++ b/test/testfile.c
@@ -55,7 +55,7 @@ rwops_error_quit(unsigned line, SDL_RWops *rwops)
 {
     SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "testfile.c(%d): failed\n", line);
     if (rwops) {
-        SDL_DestroyRW(rwops);
+        SDL_CloseRW(rwops);
     }
     cleanup();
     SDLTest_CommonDestroyState(state);
@@ -126,25 +126,25 @@ int main(int argc, char *argv[])
     if (!rwops) {
         RWOP_ERR_QUIT(rwops);
     }
-    SDL_DestroyRW(rwops);
+    SDL_CloseRW(rwops);
     unlink(FBASENAME2);
     rwops = SDL_RWFromFile(FBASENAME2, "wb+");
     if (!rwops) {
         RWOP_ERR_QUIT(rwops);
     }
-    SDL_DestroyRW(rwops);
+    SDL_CloseRW(rwops);
     unlink(FBASENAME2);
     rwops = SDL_RWFromFile(FBASENAME2, "ab");
     if (!rwops) {
         RWOP_ERR_QUIT(rwops);
     }
-    SDL_DestroyRW(rwops);
+    SDL_CloseRW(rwops);
     unlink(FBASENAME2);
     rwops = SDL_RWFromFile(FBASENAME2, "ab+");
     if (!rwops) {
         RWOP_ERR_QUIT(rwops);
     }
-    SDL_DestroyRW(rwops);
+    SDL_CloseRW(rwops);
     unlink(FBASENAME2);
     SDL_Log("test2 OK\n");
 
@@ -171,7 +171,7 @@ int main(int argc, char *argv[])
         RWOP_ERR_QUIT(rwops); /* we are in write only mode */
     }
 
-    SDL_DestroyRW(rwops);
+    SDL_CloseRW(rwops);
 
     rwops = SDL_RWFromFile(FBASENAME1, "rb"); /* read mode, file must exist */
     if (!rwops) {
@@ -208,7 +208,7 @@ int main(int argc, char *argv[])
         RWOP_ERR_QUIT(rwops); /* readonly mode */
     }
 
-    SDL_DestroyRW(rwops);
+    SDL_CloseRW(rwops);
 
     /* test 3: same with w+ mode */
     rwops = SDL_RWFromFile(FBASENAME1, "wb+"); /* write + read + truncation */
@@ -258,7 +258,7 @@ int main(int argc, char *argv[])
     if (SDL_memcmp(test_buf, "12345678901234567890", 20) != 0) {
         RWOP_ERR_QUIT(rwops);
     }
-    SDL_DestroyRW(rwops);
+    SDL_CloseRW(rwops);
     SDL_Log("test3 OK\n");
 
     /* test 4: same in r+ mode */
@@ -309,7 +309,7 @@ int main(int argc, char *argv[])
     if (SDL_memcmp(test_buf, "12345678901234567890", 20) != 0) {
         RWOP_ERR_QUIT(rwops);
     }
-    SDL_DestroyRW(rwops);
+    SDL_CloseRW(rwops);
     SDL_Log("test4 OK\n");
 
     /* test5 : append mode */
@@ -366,7 +366,7 @@ int main(int argc, char *argv[])
     if (SDL_memcmp(test_buf, "123456789012345678901234567123", 30) != 0) {
         RWOP_ERR_QUIT(rwops);
     }
-    SDL_DestroyRW(rwops);
+    SDL_CloseRW(rwops);
     SDL_Log("test5 OK\n");
     cleanup();
     SDL_Quit();
diff --git a/test/testime.c b/test/testime.c
index aa3a1f3e8ddf0..a79d77fa78a1d 100644
--- a/test/testime.c
+++ b/test/testime.c
@@ -223,7 +223,7 @@ static int unifont_init(const char *fontname)
         lineNumber++;
     } while (bytesRead > 0);
 
-    SDL_DestroyRW(hexFile);
+    SDL_CloseRW(hexFile);
     SDL_Log("unifont: Loaded %" SDL_PRIu32 " glyphs.\n", numGlyphs);
     return 0;
 }
diff --git a/test/testoverlay.c b/test/testoverlay.c
index 4a63502a82ec8..fcb8c064060bc 100644
--- a/test/testoverlay.c
+++ b/test/testoverlay.c
@@ -452,7 +452,7 @@ int main(int argc, char **argv)
 
     SDL_RWread(handle, RawMooseData, MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT);
 
-    SDL_DestroyRW(handle);
+    SDL_CloseRW(handle);
 
     /* Create the window and renderer */
     window_w = MOOSEPIC_W * scale;
diff --git a/test/testresample.c b/test/testresample.c
index 69b5db957a303..ff6607fab9a0f 100644
--- a/test/testresample.c
+++ b/test/testresample.c
@@ -117,7 +117,7 @@ int main(int argc, char **argv)
     /* write out a WAV header... */
     io = SDL_RWFromFile(file_out, "wb");
     if (!io) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "fopen('%s') failed: %s\n", file_out, SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "opening '%s' failed: %s\n", file_out, SDL_GetError());
         ret = 5;
         goto end;
     }
@@ -141,8 +141,8 @@ int main(int argc, char **argv)
     SDL_WriteU32LE(io, dst_len);                                /* size */
     SDL_RWwrite(io, dst_buf, dst_len);
 
-    if (SDL_DestroyRW(io) == -1) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "fclose('%s') failed: %s\n", file_out, SDL_GetError());
+    if (SDL_CloseRW(io) == -1) {
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "closing '%s' failed: %s\n", file_out, SDL_GetError());
         ret = 6;
         goto end;
     }
diff --git a/test/teststreaming.c b/test/teststreaming.c
index 5a55ff61f6fa1..ee89f3e284821 100644
--- a/test/teststreaming.c
+++ b/test/teststreaming.c
@@ -171,7 +171,7 @@ int main(int argc, char **argv)
         quit(2);
     }
     SDL_RWread(handle, MooseFrames, MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT);
-    SDL_DestroyRW(handle);
+    SDL_CloseRW(handle);
 
     /* Create the window and renderer */
     window = SDL_CreateWindow("Happy Moose", MOOSEPIC_W * 4, MOO

(Patch may be truncated, please check the link at the top of this post.)