Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Clean up any opened joysticks during SDL_JoystickQuit().
Browse files Browse the repository at this point in the history
Otherwise, these leak memory and maybe operating system handles.
  • Loading branch information
icculus committed Sep 1, 2011
1 parent 67390a5 commit 46c82d0
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/joystick/SDL_joystick.c
Expand Up @@ -403,9 +403,22 @@ SDL_JoystickClose(SDL_Joystick * joystick)
void
SDL_JoystickQuit(void)
{
const int numsticks = SDL_numjoysticks;
int i;

/* Stop the event polling */
SDL_numjoysticks = 0;

SDL_assert( (SDL_joysticks == NULL) == (numsticks == 0) );

for (i = 0; i < numsticks; i++) {
SDL_Joystick *stick = SDL_joysticks[i];
if (stick && (stick->ref_count >= 1)) {
stick->ref_count = 1;
SDL_JoystickClose(stick);
}
}

/* Quit the joystick setup */
SDL_SYS_JoystickQuit();
if (SDL_joysticks) {
Expand Down

0 comments on commit 46c82d0

Please sign in to comment.