test/testsprite.c
changeset 1151 be9c9c8f6d53
parent 753 b14fdadd8311
child 1214 31103dbf1c26
     1.1 --- a/test/testsprite.c	Wed Sep 28 06:38:22 2005 +0000
     1.2 +++ b/test/testsprite.c	Wed Sep 28 11:36:20 2005 +0000
     1.3 @@ -22,6 +22,13 @@
     1.4  int sprites_visible;
     1.5  Uint16 sprite_w, sprite_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  int LoadSprite(SDL_Surface *screen, char *file)
    1.15  {
    1.16  	SDL_Surface *temp;
    1.17 @@ -159,9 +166,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  	numsprites = NUM_SPRITES;
    1.27  	videoflags = SDL_SWSURFACE|SDL_ANYFORMAT;
    1.28 @@ -201,7 +207,7 @@
    1.29  			fprintf(stderr, 
    1.30  	"Usage: %s [-bpp N] [-hw] [-flip] [-fast] [-fullscreen] [numsprites]\n",
    1.31  								argv[0]);
    1.32 -			exit(1);
    1.33 +			quit(1);
    1.34  		}
    1.35  	}
    1.36  
    1.37 @@ -210,12 +216,12 @@
    1.38  	if ( ! screen ) {
    1.39  		fprintf(stderr, "Couldn't set %dx%d video mode: %s\n",
    1.40  					width, height, SDL_GetError());
    1.41 -		exit(2);
    1.42 +		quit(2);
    1.43  	}
    1.44  
    1.45  	/* Load the sprite */
    1.46  	if ( LoadSprite(screen, "icon.bmp") < 0 ) {
    1.47 -		exit(1);
    1.48 +		quit(1);
    1.49  	}
    1.50  
    1.51  	/* Allocate memory for the sprite info */
    1.52 @@ -223,7 +229,7 @@
    1.53  	if ( mem == NULL ) {
    1.54  		SDL_FreeSurface(sprite);
    1.55  		fprintf(stderr, "Out of memory!\n");
    1.56 -		exit(2);
    1.57 +		quit(2);
    1.58  	}
    1.59  	sprite_rects = (SDL_Rect *)mem;
    1.60  	positions = sprite_rects;