From 892df4bf4b38d5867916bd580d0fcaa9b346954c Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 18 Jul 2024 22:20:17 -0700 Subject: [PATCH] SDL_GetWindowICCProfile() follows the SDL_GetStringRule --- include/SDL3/SDL_video.h | 4 ++-- src/dynapi/SDL_dynapi_procs.h | 2 +- src/video/SDL_video.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/SDL3/SDL_video.h b/include/SDL3/SDL_video.h index c548bee6cc..af7d52a9ba 100644 --- a/include/SDL3/SDL_video.h +++ b/include/SDL3/SDL_video.h @@ -767,7 +767,7 @@ extern SDL_DECLSPEC const SDL_DisplayMode * SDLCALL SDL_GetWindowFullscreenMode( /** * Get the raw ICC profile data for the screen the window is currently on. * - * Data returned should be freed with SDL_free. + * The returned data follows the SDL_GetStringRule, and will be automatically freed later. * * \param window the window to query. * \param size the size of the ICC profile. @@ -776,7 +776,7 @@ extern SDL_DECLSPEC const SDL_DisplayMode * SDLCALL SDL_GetWindowFullscreenMode( * * \since This function is available since SDL 3.0.0. */ -extern SDL_DECLSPEC void * SDLCALL SDL_GetWindowICCProfile(SDL_Window *window, size_t *size); +extern SDL_DECLSPEC const void * SDLCALL SDL_GetWindowICCProfile(SDL_Window *window, size_t *size); /** * Get the pixel format associated with the window. diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index 769d1e9bb6..3dec54f509 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -515,7 +515,7 @@ SDL_DYNAPI_PROC(float,SDL_GetWindowDisplayScale,(SDL_Window *a),(a),return) SDL_DYNAPI_PROC(SDL_WindowFlags,SDL_GetWindowFlags,(SDL_Window *a),(a),return) SDL_DYNAPI_PROC(SDL_Window*,SDL_GetWindowFromID,(SDL_WindowID a),(a),return) SDL_DYNAPI_PROC(const SDL_DisplayMode*,SDL_GetWindowFullscreenMode,(SDL_Window *a),(a),return) -SDL_DYNAPI_PROC(void*,SDL_GetWindowICCProfile,(SDL_Window *a, size_t *b),(a,b),return) +SDL_DYNAPI_PROC(const void*,SDL_GetWindowICCProfile,(SDL_Window *a, size_t *b),(a,b),return) SDL_DYNAPI_PROC(SDL_WindowID,SDL_GetWindowID,(SDL_Window *a),(a),return) SDL_DYNAPI_PROC(SDL_bool,SDL_GetWindowKeyboardGrab,(SDL_Window *a),(a),return) SDL_DYNAPI_PROC(int,SDL_GetWindowMaximumSize,(SDL_Window *a, int *b, int *c),(a,b,c),return) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 6122230155..8f4ea4910b 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -2000,13 +2000,13 @@ const SDL_DisplayMode *SDL_GetWindowFullscreenMode(SDL_Window *window) } } -void *SDL_GetWindowICCProfile(SDL_Window *window, size_t *size) +const void *SDL_GetWindowICCProfile(SDL_Window *window, size_t *size) { if (!_this->GetWindowICCProfile) { SDL_Unsupported(); return NULL; } - return _this->GetWindowICCProfile(_this, window, size); + return SDL_FreeLater(_this->GetWindowICCProfile(_this, window, size)); } SDL_PixelFormat SDL_GetWindowPixelFormat(SDL_Window *window)