1.1 --- a/src/SDL.c Wed Jan 13 06:39:44 2010 +0000
1.2 +++ b/src/SDL.c Wed Jan 13 06:47:17 2010 +0000
1.3 @@ -25,6 +25,8 @@
1.4
1.5 #include "SDL.h"
1.6 #include "SDL_fatal.h"
1.7 +#include "SDL_assert.h"
1.8 +
1.9 #if !SDL_VIDEO_DISABLED
1.10 #include "video/SDL_leaks.h"
1.11 #endif
1.12 @@ -52,6 +54,9 @@
1.13 extern int SDL_HelperWindowDestroy(void);
1.14 #endif
1.15
1.16 +extern int SDL_AssertionsInit(void);
1.17 +extern void SDL_AssertionsQuit(void);
1.18 +
1.19 /* The initialized subsystems */
1.20 static Uint32 SDL_initialized = 0;
1.21 static Uint32 ticks_started = 0;
1.22 @@ -153,6 +158,10 @@
1.23 }
1.24 #endif
1.25
1.26 + if (SDL_AssertionsInit() < 0) {
1.27 + return -1;
1.28 + }
1.29 +
1.30 /* Clear the error message */
1.31 SDL_ClearError();
1.32
1.33 @@ -171,6 +180,21 @@
1.34 if (!(flags & SDL_INIT_NOPARACHUTE)) {
1.35 SDL_InstallParachute();
1.36 }
1.37 +
1.38 + /* brief sanity checks for the sanity checks. :) */
1.39 + SDL_assert(1);
1.40 + SDL_assert_release(1);
1.41 + SDL_assert_paranoid(1);
1.42 + SDL_assert(0 || 1);
1.43 + SDL_assert_release(0 || 1);
1.44 + SDL_assert_paranoid(0 || 1);
1.45 +
1.46 +#if 0 /* enable this to test assertion failures. */
1.47 + SDL_assert_release(1 == 2);
1.48 + SDL_assert_release(5 < 4);
1.49 + SDL_assert_release(0 && "This is a test");
1.50 +#endif
1.51 +
1.52 return (0);
1.53 }
1.54
1.55 @@ -239,6 +263,7 @@
1.56 fflush(stdout);
1.57 #endif
1.58
1.59 + /* !!! FIXME: make this an assertion. */
1.60 /* Print the number of surfaces not freed */
1.61 if (surfaces_allocated != 0) {
1.62 fprintf(stderr, "SDL Warning: %d SDL surfaces extant\n",
1.63 @@ -253,6 +278,8 @@
1.64 /* Uninstall any parachute signal handlers */
1.65 SDL_UninstallParachute();
1.66
1.67 + SDL_AssertionsQuit();
1.68 +
1.69 #if !SDL_THREADS_DISABLED && SDL_THREAD_PTH
1.70 pth_kill();
1.71 #endif