We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3740 - atexit() in test/testime.c
Summary: atexit() in test/testime.c
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: HG 2.0
Hardware: All All
: P2 trivial
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-13 10:47 UTC by Ozkan Sezer
Modified: 2017-08-28 02:00 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ozkan Sezer 2017-08-13 10:47:25 UTC
It is bad practice doing atexit(SDL_Quit), because calling conventions
may be different.  A quick fix for test/testime.c is using a wrapper,
like:

diff -r f7abcb63e51e test/testime.c
--- a/test/testime.c	Sun Aug 13 01:00:01 2017 -0400
+++ b/test/testime.c	Sun Aug 13 11:23:10 2017 +0300
@@ -623,6 +623,10 @@ void Redraw() {
     }
 }
 
+static void quit (void) {
+    SDL_Quit();
+}
+
 int main(int argc, char *argv[]) {
     int i, done;
     SDL_Event event;
@@ -680,7 +684,7 @@ int main(int argc, char *argv[]) {
 #endif
 
     SDL_Log("Using font: %s\n", fontname);
-    atexit(SDL_Quit);
+    atexit(quit);
 
     InitInput();
     /* Create the windows and initialize the renderers */
Comment 1 Sam Lantinga 2017-08-28 02:00:29 UTC
I removed exit() from testime, thanks!
https://hg.libsdl.org/SDL/rev/b83e2eaed190