mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-28 11:57:24 +08:00
iostream: "free*" params should be "closeio".
This commit is contained in:
@@ -1317,7 +1317,7 @@ extern DECLSPEC int SDLCALL SDL_SetAudioPostmixCallback(SDL_AudioDeviceID devid,
|
|||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* \param src The data source for the WAVE data
|
* \param src The data source for the WAVE data
|
||||||
* \param freesrc If SDL_TRUE, calls SDL_CloseIO() on `src` before returning,
|
* \param closeio If SDL_TRUE, calls SDL_CloseIO() on `src` before returning,
|
||||||
* even in the case of an error
|
* even in the case of an error
|
||||||
* \param spec A pointer to an SDL_AudioSpec that will be set to the WAVE
|
* \param spec A pointer to an SDL_AudioSpec that will be set to the WAVE
|
||||||
* data's format details on successful return
|
* data's format details on successful return
|
||||||
@@ -1344,7 +1344,7 @@ extern DECLSPEC int SDLCALL SDL_SetAudioPostmixCallback(SDL_AudioDeviceID devid,
|
|||||||
* \sa SDL_free
|
* \sa SDL_free
|
||||||
* \sa SDL_LoadWAV
|
* \sa SDL_LoadWAV
|
||||||
*/
|
*/
|
||||||
extern DECLSPEC int SDLCALL SDL_LoadWAV_IO(SDL_IOStream * src, SDL_bool freesrc,
|
extern DECLSPEC int SDLCALL SDL_LoadWAV_IO(SDL_IOStream * src, SDL_bool closeio,
|
||||||
SDL_AudioSpec * spec, Uint8 ** audio_buf,
|
SDL_AudioSpec * spec, Uint8 ** audio_buf,
|
||||||
Uint32 * audio_len);
|
Uint32 * audio_len);
|
||||||
|
|
||||||
|
|||||||
@@ -268,7 +268,7 @@ extern DECLSPEC int SDLCALL SDL_AddGamepadMapping(const char *mapping);
|
|||||||
* constrained environment.
|
* constrained environment.
|
||||||
*
|
*
|
||||||
* \param src the data stream for the mappings to be added
|
* \param src the data stream for the mappings to be added
|
||||||
* \param freesrc if SDL_TRUE, calls SDL_CloseIO() on `src` before returning,
|
* \param closeio if SDL_TRUE, calls SDL_CloseIO() on `src` before returning,
|
||||||
* even in the case of an error
|
* even in the case of an error
|
||||||
* \returns the number of mappings added or -1 on error; call SDL_GetError()
|
* \returns the number of mappings added or -1 on error; call SDL_GetError()
|
||||||
* for more information.
|
* for more information.
|
||||||
@@ -279,7 +279,7 @@ extern DECLSPEC int SDLCALL SDL_AddGamepadMapping(const char *mapping);
|
|||||||
* \sa SDL_AddGamepadMappingsFromFile
|
* \sa SDL_AddGamepadMappingsFromFile
|
||||||
* \sa SDL_GetGamepadMappingForGUID
|
* \sa SDL_GetGamepadMappingForGUID
|
||||||
*/
|
*/
|
||||||
extern DECLSPEC int SDLCALL SDL_AddGamepadMappingsFromIO(SDL_IOStream *src, SDL_bool freesrc);
|
extern DECLSPEC int SDLCALL SDL_AddGamepadMappingsFromIO(SDL_IOStream *src, SDL_bool closeio);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a set of gamepad mappings from a file.
|
* Load a set of gamepad mappings from a file.
|
||||||
|
|||||||
@@ -290,10 +290,10 @@ extern DECLSPEC SDL_IOStream *SDLCALL SDL_OpenIO(const SDL_IOStreamInterface *if
|
|||||||
/**
|
/**
|
||||||
* Close and free an allocated SDL_IOStream structure.
|
* Close and free an allocated SDL_IOStream structure.
|
||||||
*
|
*
|
||||||
* SDL_CloseIO() closes and cleans up the SDL_IOStream stream. It releases any
|
* SDL_CloseIO() closes and cleans up the SDL_IOStream stream. It releases
|
||||||
* resources used by the stream and frees the SDL_IOStream itself with
|
* any resources used by the stream and frees the SDL_IOStream itself. This
|
||||||
* SDL_CloseIO(). This returns 0 on success, or -1 if the stream failed to
|
* returns 0 on success, or -1 if the stream failed to flush to its output
|
||||||
* flush to its output (e.g. to disk).
|
* (e.g. to disk).
|
||||||
*
|
*
|
||||||
* Note that if this fails to flush the stream to disk, this function reports
|
* Note that if this fails to flush the stream to disk, this function reports
|
||||||
* an error, but the SDL_IOStream is still invalid once this function returns.
|
* an error, but the SDL_IOStream is still invalid once this function returns.
|
||||||
@@ -542,13 +542,13 @@ extern DECLSPEC size_t SDLCALL SDL_IOvprintf(SDL_IOStream *context, SDL_PRINTF_F
|
|||||||
*
|
*
|
||||||
* \param src the SDL_IOStream to read all available data from
|
* \param src the SDL_IOStream to read all available data from
|
||||||
* \param datasize if not NULL, will store the number of bytes read
|
* \param datasize if not NULL, will store the number of bytes read
|
||||||
* \param freesrc if SDL_TRUE, calls SDL_CloseIO() on `src` before returning,
|
* \param closeio if SDL_TRUE, calls SDL_CloseIO() on `src` before returning,
|
||||||
* even in the case of an error
|
* even in the case of an error
|
||||||
* \returns the data, or NULL if there was an error.
|
* \returns the data, or NULL if there was an error.
|
||||||
*
|
*
|
||||||
* \since This function is available since SDL 3.0.0.
|
* \since This function is available since SDL 3.0.0.
|
||||||
*/
|
*/
|
||||||
extern DECLSPEC void *SDLCALL SDL_LoadFile_IO(SDL_IOStream *src, size_t *datasize, SDL_bool freesrc);
|
extern DECLSPEC void *SDLCALL SDL_LoadFile_IO(SDL_IOStream *src, size_t *datasize, SDL_bool closeio);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load all the data from a file path.
|
* Load all the data from a file path.
|
||||||
|
|||||||
@@ -328,7 +328,7 @@ extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface *surface);
|
|||||||
* will result in a memory leak.
|
* will result in a memory leak.
|
||||||
*
|
*
|
||||||
* \param src the data stream for the surface
|
* \param src the data stream for the surface
|
||||||
* \param freesrc if SDL_TRUE, calls SDL_CloseIO() on `src` before returning,
|
* \param closeio if SDL_TRUE, calls SDL_CloseIO() on `src` before returning,
|
||||||
* even in the case of an error
|
* even in the case of an error
|
||||||
* \returns a pointer to a new SDL_Surface structure or NULL if there was an
|
* \returns a pointer to a new SDL_Surface structure or NULL if there was an
|
||||||
* error; call SDL_GetError() for more information.
|
* error; call SDL_GetError() for more information.
|
||||||
@@ -339,7 +339,7 @@ extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface *surface);
|
|||||||
* \sa SDL_LoadBMP
|
* \sa SDL_LoadBMP
|
||||||
* \sa SDL_SaveBMP_IO
|
* \sa SDL_SaveBMP_IO
|
||||||
*/
|
*/
|
||||||
extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_IO(SDL_IOStream *src, SDL_bool freesrc);
|
extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_IO(SDL_IOStream *src, SDL_bool closeio);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a BMP image from a file.
|
* Load a BMP image from a file.
|
||||||
@@ -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 surface the SDL_Surface structure containing the image to be saved
|
||||||
* \param dst a data stream to save to
|
* \param dst a data stream to save to
|
||||||
* \param freedst if SDL_TRUE, calls SDL_CloseIO() on `dst` before returning,
|
* \param closeio if SDL_TRUE, calls SDL_CloseIO() on `dst` before returning,
|
||||||
* even in the case of an error
|
* even in the case of an error
|
||||||
* \returns 0 on success or a negative error code on failure; call
|
* \returns 0 on success or a negative error code on failure; call
|
||||||
* SDL_GetError() for more information.
|
* SDL_GetError() for more information.
|
||||||
@@ -380,7 +380,7 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP(const char *file);
|
|||||||
* \sa SDL_LoadBMP_IO
|
* \sa SDL_LoadBMP_IO
|
||||||
* \sa SDL_SaveBMP
|
* \sa SDL_SaveBMP
|
||||||
*/
|
*/
|
||||||
extern DECLSPEC int SDLCALL SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, SDL_bool freedst);
|
extern DECLSPEC int SDLCALL SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, SDL_bool closeio);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save a surface to a file.
|
* Save a surface to a file.
|
||||||
|
|||||||
@@ -2075,7 +2075,7 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint
|
|||||||
return 0;
|
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;
|
int result = -1;
|
||||||
WaveFile file;
|
WaveFile file;
|
||||||
@@ -2110,13 +2110,13 @@ int SDL_LoadWAV_IO(SDL_IOStream *src, SDL_bool freesrc, SDL_AudioSpec *spec, Uin
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Cleanup */
|
/* Cleanup */
|
||||||
if (!freesrc) {
|
if (!closeio) {
|
||||||
SDL_SeekIO(src, file.chunk.position, SDL_IO_SEEK_SET);
|
SDL_SeekIO(src, file.chunk.position, SDL_IO_SEEK_SET);
|
||||||
}
|
}
|
||||||
WaveFreeChunkData(&file.chunk);
|
WaveFreeChunkData(&file.chunk);
|
||||||
SDL_free(file.decoderdata);
|
SDL_free(file.decoderdata);
|
||||||
done:
|
done:
|
||||||
if (freesrc && src) {
|
if (closeio && src) {
|
||||||
SDL_CloseIO(src);
|
SDL_CloseIO(src);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -763,7 +763,7 @@ int SDL_CloseIO(SDL_IOStream *iostr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Load all the data from an SDL data stream */
|
/* 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;
|
const int FILE_CHUNK_SIZE = 1024;
|
||||||
Sint64 size, size_total = 0;
|
Sint64 size, size_total = 0;
|
||||||
@@ -824,7 +824,7 @@ done:
|
|||||||
if (datasize) {
|
if (datasize) {
|
||||||
*datasize = (size_t)size_total;
|
*datasize = (size_t)size_total;
|
||||||
}
|
}
|
||||||
if (freesrc && src) {
|
if (closeio && src) {
|
||||||
SDL_CloseIO(src);
|
SDL_CloseIO(src);
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
|
|||||||
@@ -1789,7 +1789,7 @@ static GamepadMapping_t *SDL_PrivateGetGamepadMapping(SDL_JoystickID instance_id
|
|||||||
/*
|
/*
|
||||||
* Add or update an entry into the Mappings Database
|
* 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();
|
const char *platform = SDL_GetPlatform();
|
||||||
int gamepads = 0;
|
int gamepads = 0;
|
||||||
@@ -1797,7 +1797,7 @@ int SDL_AddGamepadMappingsFromIO(SDL_IOStream *src, SDL_bool freesrc)
|
|||||||
size_t db_size;
|
size_t db_size;
|
||||||
size_t platform_len;
|
size_t platform_len;
|
||||||
|
|
||||||
buf = (char *)SDL_LoadFile_IO(src, &db_size, freesrc);
|
buf = (char *)SDL_LoadFile_IO(src, &db_size, closeio);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
return SDL_SetError("Could not allocate space to read DB into memory");
|
return SDL_SetError("Could not allocate space to read DB into memory");
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -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;
|
SDL_bool was_error = SDL_TRUE;
|
||||||
Sint64 fp_offset = 0;
|
Sint64 fp_offset = 0;
|
||||||
@@ -577,7 +577,7 @@ done:
|
|||||||
SDL_DestroySurface(surface);
|
SDL_DestroySurface(surface);
|
||||||
surface = NULL;
|
surface = NULL;
|
||||||
}
|
}
|
||||||
if (freesrc && src) {
|
if (closeio && src) {
|
||||||
SDL_CloseIO(src);
|
SDL_CloseIO(src);
|
||||||
}
|
}
|
||||||
return surface;
|
return surface;
|
||||||
@@ -588,7 +588,7 @@ SDL_Surface *SDL_LoadBMP(const char *file)
|
|||||||
return SDL_LoadBMP_IO(SDL_IOFromFile(file, "rb"), 1);
|
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;
|
SDL_bool was_error = SDL_TRUE;
|
||||||
Sint64 fp_offset, new_offset;
|
Sint64 fp_offset, new_offset;
|
||||||
@@ -856,7 +856,7 @@ done:
|
|||||||
if (intermediate_surface && intermediate_surface != surface) {
|
if (intermediate_surface && intermediate_surface != surface) {
|
||||||
SDL_DestroySurface(intermediate_surface);
|
SDL_DestroySurface(intermediate_surface);
|
||||||
}
|
}
|
||||||
if (freedst && dst) {
|
if (closeio && dst) {
|
||||||
if (SDL_CloseIO(dst) < 0) {
|
if (SDL_CloseIO(dst) < 0) {
|
||||||
was_error = SDL_TRUE;
|
was_error = SDL_TRUE;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user