First pass at Ryan's assertion code, minor tweaks to come.
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404398
This commit is contained in:
parent
7f6c455755
commit
a8a1ac9acd
15 changed files with 667 additions and 1 deletions
27
src/SDL.c
27
src/SDL.c
|
@ -25,6 +25,8 @@
|
|||
|
||||
#include "SDL.h"
|
||||
#include "SDL_fatal.h"
|
||||
#include "SDL_assert.h"
|
||||
|
||||
#if !SDL_VIDEO_DISABLED
|
||||
#include "video/SDL_leaks.h"
|
||||
#endif
|
||||
|
@ -52,6 +54,9 @@ extern int SDL_HelperWindowCreate(void);
|
|||
extern int SDL_HelperWindowDestroy(void);
|
||||
#endif
|
||||
|
||||
extern int SDL_AssertionsInit(void);
|
||||
extern void SDL_AssertionsQuit(void);
|
||||
|
||||
/* The initialized subsystems */
|
||||
static Uint32 SDL_initialized = 0;
|
||||
static Uint32 ticks_started = 0;
|
||||
|
@ -153,6 +158,10 @@ SDL_Init(Uint32 flags)
|
|||
}
|
||||
#endif
|
||||
|
||||
if (SDL_AssertionsInit() < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Clear the error message */
|
||||
SDL_ClearError();
|
||||
|
||||
|
@ -171,6 +180,21 @@ SDL_Init(Uint32 flags)
|
|||
if (!(flags & SDL_INIT_NOPARACHUTE)) {
|
||||
SDL_InstallParachute();
|
||||
}
|
||||
|
||||
/* brief sanity checks for the sanity checks. :) */
|
||||
SDL_assert(1);
|
||||
SDL_assert_release(1);
|
||||
SDL_assert_paranoid(1);
|
||||
SDL_assert(0 || 1);
|
||||
SDL_assert_release(0 || 1);
|
||||
SDL_assert_paranoid(0 || 1);
|
||||
|
||||
#if 0 /* enable this to test assertion failures. */
|
||||
SDL_assert_release(1 == 2);
|
||||
SDL_assert_release(5 < 4);
|
||||
SDL_assert_release(0 && "This is a test");
|
||||
#endif
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -239,6 +263,7 @@ SDL_Quit(void)
|
|||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
/* !!! FIXME: make this an assertion. */
|
||||
/* Print the number of surfaces not freed */
|
||||
if (surfaces_allocated != 0) {
|
||||
fprintf(stderr, "SDL Warning: %d SDL surfaces extant\n",
|
||||
|
@ -253,6 +278,8 @@ SDL_Quit(void)
|
|||
/* Uninstall any parachute signal handlers */
|
||||
SDL_UninstallParachute();
|
||||
|
||||
SDL_AssertionsQuit();
|
||||
|
||||
#if !SDL_THREADS_DISABLED && SDL_THREAD_PTH
|
||||
pth_kill();
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue