test/testerror.c
changeset 1151 be9c9c8f6d53
parent 0 74212992fb08
child 1659 14717b52abc0
     1.1 --- a/test/testerror.c	Wed Sep 28 06:38:22 2005 +0000
     1.2 +++ b/test/testerror.c	Wed Sep 28 11:36:20 2005 +0000
     1.3 @@ -10,6 +10,13 @@
     1.4  
     1.5  static int alive = 0;
     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 ThreadFunc(void *data)
    1.15  {
    1.16  	/* Set the child thread error string */
    1.17 @@ -30,9 +37,8 @@
    1.18  	/* Load the SDL library */
    1.19  	if ( SDL_Init(0) < 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  	/* Set the error value for the main thread */
    1.27  	SDL_SetError("No worries");
    1.28 @@ -41,7 +47,7 @@
    1.29  	thread = SDL_CreateThread(ThreadFunc, "#1");
    1.30  	if ( thread == NULL ) {
    1.31  		fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError());
    1.32 -		exit(1);
    1.33 +		quit(1);
    1.34  	}
    1.35  	SDL_Delay(5*1000);
    1.36  	printf("Waiting for thread #1\n");
    1.37 @@ -50,5 +56,6 @@
    1.38  
    1.39  	printf("Main thread error string: %s\n", SDL_GetError());
    1.40  
    1.41 +	SDL_Quit();
    1.42  	return(0);
    1.43  }