Mercurial > sdl-ios-xcode
comparison test/testlock.c @ 1151:be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
if SDL is built with a non-cdecl calling convention, and it's just generally
bad practice anyhow.
Now programs explicitly call SDL_Quit() where appropriate, wrap SDL_Quit() in
a cdecl function where it can't be avoided, and rely on the parachute where
a crash might have hit the atexit() before (these ARE test programs, after
all!).
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Wed, 28 Sep 2005 11:36:20 +0000 |
parents | 74212992fb08 |
children | 14717b52abc0 |
comparison
equal
deleted
inserted
replaced
1150:7d8e1925f35b | 1151:be9c9c8f6d53 |
---|---|
12 #include "SDL_thread.h" | 12 #include "SDL_thread.h" |
13 | 13 |
14 static SDL_mutex *mutex = NULL; | 14 static SDL_mutex *mutex = NULL; |
15 static Uint32 mainthread; | 15 static Uint32 mainthread; |
16 static SDL_Thread *threads[6]; | 16 static SDL_Thread *threads[6]; |
17 | |
18 /* | |
19 * SDL_Quit() shouldn't be used with atexit() directly because | |
20 * calling conventions may differ... | |
21 */ | |
22 static void SDL_Quit_Wrapper(void) | |
23 { | |
24 SDL_Quit(); | |
25 } | |
17 | 26 |
18 void printid(void) | 27 void printid(void) |
19 { | 28 { |
20 printf("Process %u: exiting\n", SDL_ThreadID()); | 29 printf("Process %u: exiting\n", SDL_ThreadID()); |
21 } | 30 } |
66 /* Load the SDL library */ | 75 /* Load the SDL library */ |
67 if ( SDL_Init(0) < 0 ) { | 76 if ( SDL_Init(0) < 0 ) { |
68 fprintf(stderr, "%s\n", SDL_GetError()); | 77 fprintf(stderr, "%s\n", SDL_GetError()); |
69 exit(1); | 78 exit(1); |
70 } | 79 } |
71 atexit(SDL_Quit); | 80 atexit(SDL_Quit_Wrapper); |
72 | 81 |
73 if ( (mutex=SDL_CreateMutex()) == NULL ) { | 82 if ( (mutex=SDL_CreateMutex()) == NULL ) { |
74 fprintf(stderr, "Couldn't create mutex: %s\n", SDL_GetError()); | 83 fprintf(stderr, "Couldn't create mutex: %s\n", SDL_GetError()); |
75 exit(1); | 84 exit(1); |
76 } | 85 } |