Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Correctness patch, it's up to the SDL_haptic.c to clean up effects, n…
…ot SDL_syshaptic.c.
  • Loading branch information
bobbens committed Jul 31, 2008
1 parent f27d558 commit 8053281deb7f199a904daf477a93abdc20d4c70e
Showing with 12 additions and 25 deletions.
  1. +1 −0 src/haptic/SDL_haptic.c
  2. +2 −10 src/haptic/darwin/SDL_syshaptic.c
  3. +7 −2 src/haptic/linux/SDL_syshaptic.c
  4. +2 −13 src/haptic/win32/SDL_syshaptic.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;
@@ -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; i<haptic->neffects; 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 */
@@ -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. */
@@ -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; i<haptic->neffects; 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 */

0 comments on commit 8053281

Please sign in to comment.