Sign in to follow this  
GenuineXP

SDL Initialization

Recommended Posts

GenuineXP    262
Is this safe?
...
SDL_Init(...);
SDL_Init(...);
SDL_Init(...);
SDL_Init(...);
...
// Use SDL here.
...
SDL_Quit();
SDL_Quit();
SDL_Quit();
SDL_Quit();
...
Note that the only place actual SDL calls would be is in between the initialization and shut down calls (where the comment is). I ask this question because I'm not sure how to approach writing plugins for my engine. Several plugins are SDL-based, and I'm curious if each plugin were to initialize SDL and also shut it down when unloaded if things would blow up. (Plugins would not be unloaded until the entire engine is shut down, so one plugin shutting down SDL while other plugins are still using SDL isn't an issue.) I nifty way to sidestep this problem is writing a primer plugin that initializes a library and keeps a reference count, only actually initializing/freeing when appropriate... but I want to avoid this if I can. In either case, I'm wondering if SDL can take this sort of abuse. Thanks!

Share this post


Link to post
Share on other sites
SiCrane    11839
At least in 1.2.13, it's safe to call SDL_Quit() multiple times, but the first SDL_Quit() call will cleanup the SDL resources.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this