test/testcdrom.c
changeset 1151 be9c9c8f6d53
parent 613 9c6717a1c66f
child 1154 d93862a3d821
     1.1 --- a/test/testcdrom.c	Wed Sep 28 06:38:22 2005 +0000
     1.2 +++ b/test/testcdrom.c	Wed Sep 28 11:36:20 2005 +0000
     1.3 @@ -7,6 +7,12 @@
     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 PrintStatus(int driveindex, SDL_CD *cdrom)
    1.15  {
    1.16 @@ -92,14 +98,13 @@
    1.17  	/* Initialize SDL first */
    1.18  	if ( SDL_Init(SDL_INIT_CDROM) < 0 ) {
    1.19  		fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
    1.20 -		exit(1);
    1.21 +		return(1);
    1.22  	}
    1.23 -	atexit(SDL_Quit);
    1.24  
    1.25  	/* Find out how many CD-ROM drives are connected to the system */
    1.26  	if ( SDL_CDNumDrives() == 0 ) {
    1.27  		printf("No CD-ROM devices detected\n");
    1.28 -		exit(0);
    1.29 +		quit(0);
    1.30  	}
    1.31  	printf("Drives available: %d\n", SDL_CDNumDrives());
    1.32  	for ( i=0; i<SDL_CDNumDrives(); ++i ) {
    1.33 @@ -116,7 +121,7 @@
    1.34  	if ( cdrom == NULL ) {
    1.35  		fprintf(stderr, "Couldn't open drive %d: %s\n", drive,
    1.36  							SDL_GetError());
    1.37 -		exit(2);
    1.38 +		quit(2);
    1.39  	}
    1.40  #ifdef TEST_NULLCD
    1.41  	cdrom = NULL;
    1.42 @@ -192,11 +197,12 @@
    1.43  		} else {
    1.44  			PrintUsage(argv[0]);
    1.45  			SDL_CDClose(cdrom);
    1.46 -			exit(1);
    1.47 +			quit(1);
    1.48  		}
    1.49  	}
    1.50  	PrintStatus(drive, cdrom);
    1.51  	SDL_CDClose(cdrom);
    1.52 +	SDL_Quit();
    1.53  
    1.54  	return(0);
    1.55  }