test/checkkeys.c
changeset 1151 be9c9c8f6d53
parent 493 806fcbde0af3
child 1253 7c7ddaf195bf
     1.1 --- a/test/checkkeys.c	Wed Sep 28 06:38:22 2005 +0000
     1.2 +++ b/test/checkkeys.c	Wed Sep 28 11:36:20 2005 +0000
     1.3 @@ -10,6 +10,13 @@
     1.4  
     1.5  #include "SDL.h"
     1.6  
     1.7 +/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
     1.8 +static void quit(int rc)
     1.9 +{
    1.10 +	SDL_Quit();
    1.11 +	exit(rc);
    1.12 +}
    1.13 +
    1.14  static void print_modifiers(void)
    1.15  {
    1.16  	int mod;
    1.17 @@ -82,9 +89,8 @@
    1.18  	/* Initialize SDL */
    1.19  	if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
    1.20  		fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
    1.21 -		exit(1);
    1.22 +		return(1);
    1.23  	}
    1.24 -	atexit(SDL_Quit);
    1.25  
    1.26  	videoflags = SDL_SWSURFACE;
    1.27  	while( argc > 1 ) {
    1.28 @@ -93,7 +99,7 @@
    1.29  			videoflags |= SDL_FULLSCREEN;
    1.30  		} else {
    1.31  			fprintf(stderr, "Usage: %s [-fullscreen]\n", argv[0]);
    1.32 -			exit(1);
    1.33 +			quit(1);
    1.34  		}
    1.35  	}
    1.36  
    1.37 @@ -101,7 +107,7 @@
    1.38  	if ( SDL_SetVideoMode(640, 480, 0, videoflags) == NULL ) {
    1.39  		fprintf(stderr, "Couldn't set 640x480 video mode: %s\n",
    1.40  							SDL_GetError());
    1.41 -		exit(2);
    1.42 +		quit(2);
    1.43  	}
    1.44  
    1.45  	/* Enable UNICODE translation for keyboard input */
    1.46 @@ -132,5 +138,7 @@
    1.47  				break;
    1.48  		}
    1.49  	}
    1.50 +
    1.51 +	SDL_Quit();
    1.52  	return(0);
    1.53  }