iostream: "free*" params should be "closeio".

This commit is contained in:
Ryan C. Gordon
2024-03-14 23:14:46 -04:00
parent 5440fd7d12
commit 6776b6108a
8 changed files with 25 additions and 25 deletions

View File

@@ -2075,7 +2075,7 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint
return 0;
}
int SDL_LoadWAV_IO(SDL_IOStream *src, SDL_bool freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
int SDL_LoadWAV_IO(SDL_IOStream *src, SDL_bool closeio, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
{
int result = -1;
WaveFile file;
@@ -2110,13 +2110,13 @@ int SDL_LoadWAV_IO(SDL_IOStream *src, SDL_bool freesrc, SDL_AudioSpec *spec, Uin
}
/* Cleanup */
if (!freesrc) {
if (!closeio) {
SDL_SeekIO(src, file.chunk.position, SDL_IO_SEEK_SET);
}
WaveFreeChunkData(&file.chunk);
SDL_free(file.decoderdata);
done:
if (freesrc && src) {
if (closeio && src) {
SDL_CloseIO(src);
}
return result;

View File

@@ -763,7 +763,7 @@ int SDL_CloseIO(SDL_IOStream *iostr)
}
/* Load all the data from an SDL data stream */
void *SDL_LoadFile_IO(SDL_IOStream *src, size_t *datasize, SDL_bool freesrc)
void *SDL_LoadFile_IO(SDL_IOStream *src, size_t *datasize, SDL_bool closeio)
{
const int FILE_CHUNK_SIZE = 1024;
Sint64 size, size_total = 0;
@@ -824,7 +824,7 @@ done:
if (datasize) {
*datasize = (size_t)size_total;
}
if (freesrc && src) {
if (closeio && src) {
SDL_CloseIO(src);
}
return data;

View File

@@ -1789,7 +1789,7 @@ static GamepadMapping_t *SDL_PrivateGetGamepadMapping(SDL_JoystickID instance_id
/*
* Add or update an entry into the Mappings Database
*/
int SDL_AddGamepadMappingsFromIO(SDL_IOStream *src, SDL_bool freesrc)
int SDL_AddGamepadMappingsFromIO(SDL_IOStream *src, SDL_bool closeio)
{
const char *platform = SDL_GetPlatform();
int gamepads = 0;
@@ -1797,7 +1797,7 @@ int SDL_AddGamepadMappingsFromIO(SDL_IOStream *src, SDL_bool freesrc)
size_t db_size;
size_t platform_len;
buf = (char *)SDL_LoadFile_IO(src, &db_size, freesrc);
buf = (char *)SDL_LoadFile_IO(src, &db_size, closeio);
if (!buf) {
return SDL_SetError("Could not allocate space to read DB into memory");
}

View File

@@ -193,7 +193,7 @@ static void CorrectAlphaChannel(SDL_Surface *surface)
}
}
SDL_Surface *SDL_LoadBMP_IO(SDL_IOStream *src, SDL_bool freesrc)
SDL_Surface *SDL_LoadBMP_IO(SDL_IOStream *src, SDL_bool closeio)
{
SDL_bool was_error = SDL_TRUE;
Sint64 fp_offset = 0;
@@ -577,7 +577,7 @@ done:
SDL_DestroySurface(surface);
surface = NULL;
}
if (freesrc && src) {
if (closeio && src) {
SDL_CloseIO(src);
}
return surface;
@@ -588,7 +588,7 @@ SDL_Surface *SDL_LoadBMP(const char *file)
return SDL_LoadBMP_IO(SDL_IOFromFile(file, "rb"), 1);
}
int SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, SDL_bool freedst)
int SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, SDL_bool closeio)
{
SDL_bool was_error = SDL_TRUE;
Sint64 fp_offset, new_offset;
@@ -856,7 +856,7 @@ done:
if (intermediate_surface && intermediate_surface != surface) {
SDL_DestroySurface(intermediate_surface);
}
if (freedst && dst) {
if (closeio && dst) {
if (SDL_CloseIO(dst) < 0) {
was_error = SDL_TRUE;
}