rwops: Renamed SDL_CreateRW and SDL_DestroyRW to SDL_OpenRW and SDL_CloseRW.

This commit is contained in:
Ryan C. Gordon
2024-03-12 09:01:37 -04:00
parent 525919b315
commit 655ceb3b31
22 changed files with 81 additions and 95 deletions

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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: *;
};

View File

@@ -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

View File

@@ -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)

View File

@@ -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 @@ done:
*datasize = (size_t)size_total;
}
if (freesrc && src) {
SDL_DestroyRW(src);
SDL_CloseRW(src);
}
return data;
}

View File

@@ -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;

View File

@@ -578,7 +578,7 @@ done:
surface = NULL;
}
if (freesrc && src) {
SDL_DestroyRW(src);
SDL_CloseRW(src);
}
return surface;
}
@@ -857,7 +857,7 @@ done:
SDL_DestroySurface(intermediate_surface);
}
if (freedst && dst) {
if (SDL_DestroyRW(dst) < 0) {
if (SDL_CloseRW(dst) < 0) {
was_error = SDL_TRUE;
}
}