test/testpalette.c
changeset 1151 be9c9c8f6d53
parent 0 74212992fb08
child 1429 aff0170f9f1b
     1.1 --- a/test/testpalette.c	Wed Sep 28 06:38:22 2005 +0000
     1.2 +++ b/test/testpalette.c	Wed Sep 28 11:36:20 2005 +0000
     1.3 @@ -54,10 +54,17 @@
     1.4      {0,39,172}, {0,28,152}, {0,17,132}, {0,7,114}
     1.5  };
     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 sdlerr(char *when)
    1.15  {
    1.16      fprintf(stderr, "SDL error: %s: %s\n", when, SDL_GetError());
    1.17 -    exit(1);
    1.18 +    quit(1);
    1.19  }
    1.20  
    1.21  /* create a background surface */
    1.22 @@ -139,8 +146,6 @@
    1.23      if(SDL_Init(SDL_INIT_VIDEO) < 0)
    1.24  	sdlerr("initialising SDL");
    1.25  
    1.26 -    atexit(SDL_Quit);
    1.27 -
    1.28      while(--argc) {
    1.29  	++argv;
    1.30  	if(strcmp(*argv, "-hw") == 0)
    1.31 @@ -157,7 +162,7 @@
    1.32  	    fprintf(stderr,
    1.33  		    "usage: testpalette "
    1.34  		    " [-hw] [-fullscreen] [-nofade] [-gamma] [-gammaramp]\n");
    1.35 -	    return 1;
    1.36 +	    quit(1);
    1.37  	}
    1.38      }
    1.39  
    1.40 @@ -165,7 +170,7 @@
    1.41      if(!(screen = SDL_SetVideoMode(SCRW, SCRH, 8, vidflags | SDL_HWPALETTE))) {
    1.42  	fprintf(stderr, "error setting %dx%d 8bpp indexed mode: %s\n",
    1.43  		SCRW, SCRH, SDL_GetError());
    1.44 -	return 1;
    1.45 +	quit(1);
    1.46      }
    1.47  
    1.48      if(!(boat[0] = SDL_LoadBMP("sail.bmp")))
    1.49 @@ -327,6 +332,8 @@
    1.50  
    1.51      printf("%d frames, %.2f fps\n",
    1.52  	   frames, 1000.0 * frames / (SDL_GetTicks() - start));
    1.53 +
    1.54 +    SDL_Quit();
    1.55      return 0;
    1.56  }
    1.57