Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libSDL
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
libSDL
Commits
b94f23a4
Commit
b94f23a4
authored
Apr 19, 2011
by
Ryan C. Gordon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed assertion list terminator (just do it like a normal linked list).
parent
782b8b7d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
19 deletions
+11
-19
SDL_assert.h
include/SDL_assert.h
+2
-3
SDL_assert.c
src/SDL_assert.c
+9
-16
No files found.
include/SDL_assert.h
View file @
b94f23a4
...
@@ -205,7 +205,7 @@ extern DECLSPEC void SDLCALL SDL_SetAssertionHandler(
...
@@ -205,7 +205,7 @@ extern DECLSPEC void SDLCALL SDL_SetAssertionHandler(
*
*
* <code>
* <code>
* const SDL_assert_data *item = SDL_GetAssertionReport();
* const SDL_assert_data *item = SDL_GetAssertionReport();
* while (item
->condition
) {
* while (item) {
* printf("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\n",
* printf("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\n",
* item->condition, item->function, item->filename,
* item->condition, item->function, item->filename,
* item->linenum, item->trigger_count,
* item->linenum, item->trigger_count,
...
@@ -214,8 +214,7 @@ extern DECLSPEC void SDLCALL SDL_SetAssertionHandler(
...
@@ -214,8 +214,7 @@ extern DECLSPEC void SDLCALL SDL_SetAssertionHandler(
* }
* }
* </code>
* </code>
*
*
* \return List of all assertions. This never returns NULL,
* \return List of all assertions.
* even if there are no items.
* \sa SDL_ResetAssertionReport
* \sa SDL_ResetAssertionReport
*/
*/
extern
DECLSPEC
const
SDL_assert_data
*
SDLCALL
SDL_GetAssertionReport
(
void
);
extern
DECLSPEC
const
SDL_assert_data
*
SDLCALL
SDL_GetAssertionReport
(
void
);
...
...
src/SDL_assert.c
View file @
b94f23a4
...
@@ -44,8 +44,7 @@ SDL_PromptAssertion(const SDL_assert_data *data, void *userdata);
...
@@ -44,8 +44,7 @@ SDL_PromptAssertion(const SDL_assert_data *data, void *userdata);
* We keep all triggered assertions in a singly-linked list so we can
* We keep all triggered assertions in a singly-linked list so we can
* generate a report later.
* generate a report later.
*/
*/
static
SDL_assert_data
assertion_list_terminator
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
};
static
SDL_assert_data
*
triggered_assertions
=
NULL
;
static
SDL_assert_data
*
triggered_assertions
=
&
assertion_list_terminator
;
static
SDL_mutex
*
assertion_mutex
=
NULL
;
static
SDL_mutex
*
assertion_mutex
=
NULL
;
static
SDL_AssertionHandler
assertion_handler
=
SDL_PromptAssertion
;
static
SDL_AssertionHandler
assertion_handler
=
SDL_PromptAssertion
;
...
@@ -217,7 +216,8 @@ static void SDL_AddAssertionToReport(SDL_assert_data *data)
...
@@ -217,7 +216,8 @@ static void SDL_AddAssertionToReport(SDL_assert_data *data)
{
{
/* (data) is always a static struct defined with the assert macros, so
/* (data) is always a static struct defined with the assert macros, so
we don't have to worry about copying or allocating them. */
we don't have to worry about copying or allocating them. */
if
(
data
->
next
==
NULL
)
{
/* not yet added? */
data
->
trigger_count
++
;
if
(
data
->
trigger_count
==
1
)
{
/* not yet added? */
data
->
next
=
triggered_assertions
;
data
->
next
=
triggered_assertions
;
triggered_assertions
=
data
;
triggered_assertions
=
data
;
}
}
...
@@ -226,19 +226,14 @@ static void SDL_AddAssertionToReport(SDL_assert_data *data)
...
@@ -226,19 +226,14 @@ static void SDL_AddAssertionToReport(SDL_assert_data *data)
static
void
SDL_GenerateAssertionReport
(
void
)
static
void
SDL_GenerateAssertionReport
(
void
)
{
{
const
SDL_assert_data
*
item
;
const
SDL_assert_data
*
item
=
triggered_assertions
;
/* only do this if the app hasn't assigned an assertion handler. */
/* only do this if the app hasn't assigned an assertion handler. */
if
(
assertion_handler
!=
SDL_PromptAssertion
)
if
((
item
!=
NULL
)
&&
(
assertion_handler
!=
SDL_PromptAssertion
))
{
return
;
item
=
SDL_GetAssertionReport
();
if
(
item
->
condition
)
{
debug_print
(
"
\n\n
SDL assertion report.
\n
"
);
debug_print
(
"
\n\n
SDL assertion report.
\n
"
);
debug_print
(
"All SDL assertions between last init/quit:
\n\n
"
);
debug_print
(
"All SDL assertions between last init/quit:
\n\n
"
);
while
(
item
->
condition
)
{
while
(
item
!=
NULL
)
{
debug_print
(
debug_print
(
"'%s'
\n
"
"'%s'
\n
"
" * %s (%s:%d)
\n
"
" * %s (%s:%d)
\n
"
...
@@ -398,8 +393,6 @@ SDL_ReportAssertion(SDL_assert_data *data, const char *func, const char *file,
...
@@ -398,8 +393,6 @@ SDL_ReportAssertion(SDL_assert_data *data, const char *func, const char *file,
SDL_AddAssertionToReport
(
data
);
SDL_AddAssertionToReport
(
data
);
data
->
trigger_count
++
;
assertion_running
++
;
assertion_running
++
;
if
(
assertion_running
>
1
)
{
/* assert during assert! Abort. */
if
(
assertion_running
>
1
)
{
/* assert during assert! Abort. */
if
(
assertion_running
==
2
)
{
if
(
assertion_running
==
2
)
{
...
@@ -472,16 +465,16 @@ const SDL_assert_data *SDL_GetAssertionReport(void)
...
@@ -472,16 +465,16 @@ const SDL_assert_data *SDL_GetAssertionReport(void)
void
SDL_ResetAssertionReport
(
void
)
void
SDL_ResetAssertionReport
(
void
)
{
{
SDL_assert_data
*
item
=
triggered_assertions
;
SDL_assert_data
*
next
=
NULL
;
SDL_assert_data
*
next
=
NULL
;
for
(
item
=
triggered_assertions
;
item
->
condition
;
item
=
next
)
{
SDL_assert_data
*
item
;
for
(
item
=
triggered_assertions
;
item
!=
NULL
;
item
=
next
)
{
next
=
(
SDL_assert_data
*
)
item
->
next
;
next
=
(
SDL_assert_data
*
)
item
->
next
;
item
->
always_ignore
=
SDL_FALSE
;
item
->
always_ignore
=
SDL_FALSE
;
item
->
trigger_count
=
0
;
item
->
trigger_count
=
0
;
item
->
next
=
NULL
;
item
->
next
=
NULL
;
}
}
triggered_assertions
=
&
assertion_list_terminator
;
triggered_assertions
=
NULL
;
}
}
/* vi: set ts=4 sw=4 expandtab: */
/* vi: set ts=4 sw=4 expandtab: */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment