From 8053281deb7f199a904daf477a93abdc20d4c70e Mon Sep 17 00:00:00 2001 From: Edgar Simo Date: Thu, 31 Jul 2008 09:45:27 +0000 Subject: [PATCH] Correctness patch, it's up to the SDL_haptic.c to clean up effects, not SDL_syshaptic.c. --- src/haptic/SDL_haptic.c | 1 + src/haptic/darwin/SDL_syshaptic.c | 12 ++---------- src/haptic/linux/SDL_syshaptic.c | 9 +++++++-- src/haptic/win32/SDL_syshaptic.c | 15 ++------------- 4 files changed, 12 insertions(+), 25 deletions(-) diff --git a/src/haptic/SDL_haptic.c b/src/haptic/SDL_haptic.c index 74ca8f264..8cca96fca 100644 --- a/src/haptic/SDL_haptic.c +++ b/src/haptic/SDL_haptic.c @@ -322,6 +322,7 @@ SDL_HapticClose(SDL_Haptic * haptic) /* Remove from the list */ for (i = 0; SDL_haptics[i]; ++i) { if (haptic == SDL_haptics[i]) { + SDL_haptics[i] = NULL; SDL_memcpy(&SDL_haptics[i], &SDL_haptics[i + 1], (SDL_numhaptics - i) * sizeof(haptic)); break; diff --git a/src/haptic/darwin/SDL_syshaptic.c b/src/haptic/darwin/SDL_syshaptic.c index af196a624..2b0d98e09 100644 --- a/src/haptic/darwin/SDL_syshaptic.c +++ b/src/haptic/darwin/SDL_syshaptic.c @@ -470,19 +470,11 @@ SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) void SDL_SYS_HapticClose(SDL_Haptic * haptic) { - int i; - if (haptic->hwdata) { - /* Free the effects. */ - for (i=0; ineffects; i++) { - if (haptic->effects[i].hweffect != NULL) { - SDL_SYS_HapticFreeFFEFFECT(&haptic->effects[i].hweffect->effect, - haptic->effects[i].effect.type); - SDL_free(haptic->effects[i].hweffect); - } - } + /* Free Effects. */ SDL_free(haptic->effects); + haptic->effects = NULL; haptic->neffects = 0; /* Clean up */ diff --git a/src/haptic/linux/SDL_syshaptic.c b/src/haptic/linux/SDL_syshaptic.c index 6e14090a6..58ab0cdf3 100644 --- a/src/haptic/linux/SDL_syshaptic.c +++ b/src/haptic/linux/SDL_syshaptic.c @@ -423,12 +423,17 @@ SDL_SYS_HapticClose(SDL_Haptic * haptic) { if (haptic->hwdata) { + /* Free effects. */ + SDL_free(haptic->effects); + haptic->effects = NULL; + haptic->neffects = 0; + /* Clean up */ close(haptic->hwdata->fd); /* Free */ - SDL_free(haptic->hwdata); - SDL_free(haptic->effects); + SDL_free(haptic->hwdata); + haptic->hwdata = NULL; } /* Clear the rest. */ diff --git a/src/haptic/win32/SDL_syshaptic.c b/src/haptic/win32/SDL_syshaptic.c index e7a8dc934..baf6b3c70 100644 --- a/src/haptic/win32/SDL_syshaptic.c +++ b/src/haptic/win32/SDL_syshaptic.c @@ -361,9 +361,6 @@ SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic, DIDEVICEINSTANCE instance) return 0; /* Error handling */ -open_err: - IDirectInputDevice_Release(device); - goto creat_err; acquire_err: IDirectInputDevice2_Unacquire(haptic->hwdata->device); query_err: @@ -435,19 +432,11 @@ SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) void SDL_SYS_HapticClose(SDL_Haptic * haptic) { - int i; - if (haptic->hwdata) { - /* Free the effects. */ - for (i=0; ineffects; i++) { - if (haptic->effects[i].hweffect != NULL) { - SDL_SYS_HapticFreeFFEFFECT( &haptic->effects[i].hweffect->effect, - haptic->effects[i].effect.type ); - SDL_free(haptic->effects[i].hweffect); - } - } + /* Free effects. */ SDL_free(haptic->effects); + haptic->effects = NULL; haptic->neffects = 0; /* Clean up */