summaryrefslogtreecommitdiff
path: root/src/sdl/sdl_glimp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sdl/sdl_glimp.c')
-rw-r--r--src/sdl/sdl_glimp.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/sdl/sdl_glimp.c b/src/sdl/sdl_glimp.c
index 51b448a2..1f45551f 100644
--- a/src/sdl/sdl_glimp.c
+++ b/src/sdl/sdl_glimp.c
@@ -135,7 +135,8 @@ static void GLimp_DetectAvailableModes(void)
{
int i, j;
char buf[ MAX_STRING_CHARS ] = { 0 };
- SDL_Rect modes[ 128 ];
+ size_t numSDLModes;
+ SDL_Rect *modes;
int numModes = 0;
int display = SDL_GetWindowDisplayIndex( SDL_window );
@@ -147,7 +148,14 @@ static void GLimp_DetectAvailableModes(void)
return;
}
- for( i = 0; i < SDL_GetNumDisplayModes( display ); i++ )
+ numSDLModes = SDL_GetNumDisplayModes( display );
+ modes = SDL_calloc( numSDLModes, sizeof( SDL_Rect ));
+ if ( !modes )
+ {
+ ri.Error( ERR_FATAL, "Out of memory\n" );
+ }
+
+ for( i = 0; i < numSDLModes; i++ )
{
SDL_DisplayMode mode;
@@ -157,6 +165,7 @@ static void GLimp_DetectAvailableModes(void)
if( !mode.w || !mode.h )
{
ri.Printf( PRINT_ALL, "Display supports any resolution\n" );
+ SDL_free( modes );
return;
}
@@ -198,6 +207,7 @@ static void GLimp_DetectAvailableModes(void)
ri.Printf( PRINT_ALL, "Available modes: '%s'\n", buf );
ri.Cvar_Set( "r_availableModes", buf );
}
+ SDL_free( modes );
}
#define R_FAILSAFE_WIDTH 640