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

Commit

Permalink
Browse files Browse the repository at this point in the history
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 8053281
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 25 deletions.
1 change: 1 addition & 0 deletions src/haptic/SDL_haptic.c
Expand Up @@ -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;
Expand Down
12 changes: 2 additions & 10 deletions src/haptic/darwin/SDL_syshaptic.c
Expand Up @@ -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 */
Expand Down
9 changes: 7 additions & 2 deletions src/haptic/linux/SDL_syshaptic.c
Expand 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. */
Expand Down
15 changes: 2 additions & 13 deletions src/haptic/win32/SDL_syshaptic.c
Expand Up @@ -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:
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit 8053281

Please sign in to comment.