Fixed part of bug #926883 (Video mode matching code, memory leaks,

fullscreen), i.e. memory leak caused by not freeing the mode lines
returned by XF86VidModeGetAllModeLines


git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@557 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
spanne 2005-01-03 14:14:56 +00:00
parent 2e4ddfd047
commit f7ef083831
2 changed files with 19 additions and 15 deletions

View File

@ -891,3 +891,7 @@ default.
(232) Improved error message a bit when no suitable visual could be found (232) Improved error message a bit when no suitable visual could be found
(X11 only). (X11 only).
(233) Fixed part of bug #926883 (Video mode matching code, memory leaks,
fullscreen), i.e. memory leak caused by not freeing the mode lines returned
by XF86VidModeGetAllModeLines

View File

@ -180,9 +180,10 @@ static void fghRestoreState( void )
*/ */
XFlush( fgDisplay.Display ); XFlush( fgDisplay.Display );
return; break;
} }
} }
XFree( displayModes );
} }
# else # else
@ -217,6 +218,7 @@ static GLboolean fghCheckDisplayMode( int width, int height, int depth, int refr
*/ */
static GLboolean fghChangeDisplayMode( GLboolean haveToTest ) static GLboolean fghChangeDisplayMode( GLboolean haveToTest )
{ {
GLboolean success = GL_FALSE;
#if TARGET_HOST_UNIX_X11 #if TARGET_HOST_UNIX_X11
/* /*
@ -249,22 +251,21 @@ static GLboolean fghChangeDisplayMode( GLboolean haveToTest )
fgState.GameModeDepth, fgState.GameModeDepth,
fgState.GameModeRefresh ) ) fgState.GameModeRefresh ) )
{ {
if( haveToTest )
return GL_TRUE;
/* OKi, this is the display mode we have been looking for... */ /* OKi, this is the display mode we have been looking for... */
if( !haveToTest ) {
XF86VidModeSwitchToMode( XF86VidModeSwitchToMode(
fgDisplay.Display, fgDisplay.Display,
fgDisplay.Screen, fgDisplay.Screen,
displayModes[ i ] displayModes[ i ]
); );
return GL_TRUE; }
success = GL_TRUE;
break;
} }
} }
XFree( displayModes );
} }
/* Something must have gone wrong */
return GL_FALSE;
# else # else
/* /*
* XXX warning fghChangeDisplayMode: missing XFree86 video mode extensions, * XXX warning fghChangeDisplayMode: missing XFree86 video mode extensions,
@ -275,7 +276,6 @@ static GLboolean fghChangeDisplayMode( GLboolean haveToTest )
#elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE #elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
unsigned int displayModes = 0, mode = 0xffffffff; unsigned int displayModes = 0, mode = 0xffffffff;
GLboolean success = GL_FALSE;
/* HDC desktopDC; */ /* HDC desktopDC; */
DEVMODE devMode; DEVMODE devMode;
@ -341,9 +341,9 @@ static GLboolean fghChangeDisplayMode( GLboolean haveToTest )
} }
} }
return success;
#endif #endif
return success;
} }