Correctness patch, it's up to the SDL_haptic.c to clean up effects, not SDL_syshaptic.c. gsoc2008_force_feedback
authorEdgar Simo <bobbens@gmail.com>
Thu, 31 Jul 2008 09:45:27 +0000
branchgsoc2008_force_feedback
changeset 25613696b9ce8a37
parent 2560 2274406ba792
child 2562 c284ce0cd8e0
Correctness patch, it's up to the SDL_haptic.c to clean up effects, not SDL_syshaptic.c.
src/haptic/SDL_haptic.c
src/haptic/darwin/SDL_syshaptic.c
src/haptic/linux/SDL_syshaptic.c
src/haptic/win32/SDL_syshaptic.c
     1.1 --- a/src/haptic/SDL_haptic.c	Thu Jul 31 09:02:43 2008 +0000
     1.2 +++ b/src/haptic/SDL_haptic.c	Thu Jul 31 09:45:27 2008 +0000
     1.3 @@ -322,6 +322,7 @@
     1.4     /* Remove from the list */
     1.5     for (i = 0; SDL_haptics[i]; ++i) {
     1.6        if (haptic == SDL_haptics[i]) {
     1.7 +         SDL_haptics[i] = NULL;
     1.8           SDL_memcpy(&SDL_haptics[i], &SDL_haptics[i + 1],
     1.9                 (SDL_numhaptics - i) * sizeof(haptic));
    1.10           break;
     2.1 --- a/src/haptic/darwin/SDL_syshaptic.c	Thu Jul 31 09:02:43 2008 +0000
     2.2 +++ b/src/haptic/darwin/SDL_syshaptic.c	Thu Jul 31 09:45:27 2008 +0000
     2.3 @@ -470,19 +470,11 @@
     2.4  void
     2.5  SDL_SYS_HapticClose(SDL_Haptic * haptic)
     2.6  {
     2.7 -   int i;
     2.8 -
     2.9     if (haptic->hwdata) {
    2.10  
    2.11 -      /* Free the effects. */
    2.12 -      for (i=0; i<haptic->neffects; i++) {        
    2.13 -         if (haptic->effects[i].hweffect != NULL) {
    2.14 -            SDL_SYS_HapticFreeFFEFFECT(&haptic->effects[i].hweffect->effect,
    2.15 -                                       haptic->effects[i].effect.type);
    2.16 -            SDL_free(haptic->effects[i].hweffect);
    2.17 -         } 
    2.18 -      }    
    2.19 +      /* Free Effects. */
    2.20        SDL_free(haptic->effects);
    2.21 +      haptic->effects = NULL;
    2.22        haptic->neffects = 0;
    2.23  
    2.24        /* Clean up */
     3.1 --- a/src/haptic/linux/SDL_syshaptic.c	Thu Jul 31 09:02:43 2008 +0000
     3.2 +++ b/src/haptic/linux/SDL_syshaptic.c	Thu Jul 31 09:45:27 2008 +0000
     3.3 @@ -423,12 +423,17 @@
     3.4  {
     3.5     if (haptic->hwdata) {
     3.6  
     3.7 +      /* Free effects. */
     3.8 +      SDL_free(haptic->effects);
     3.9 +      haptic->effects = NULL;
    3.10 +      haptic->neffects = 0;
    3.11 +
    3.12        /* Clean up */
    3.13        close(haptic->hwdata->fd);
    3.14  
    3.15        /* Free */
    3.16 -      SDL_free(haptic->hwdata);
    3.17 -      SDL_free(haptic->effects);
    3.18 +      SDL_free(haptic->hwdata);                                           
    3.19 +      haptic->hwdata = NULL;  
    3.20     }
    3.21  
    3.22     /* Clear the rest. */
     4.1 --- a/src/haptic/win32/SDL_syshaptic.c	Thu Jul 31 09:02:43 2008 +0000
     4.2 +++ b/src/haptic/win32/SDL_syshaptic.c	Thu Jul 31 09:45:27 2008 +0000
     4.3 @@ -361,9 +361,6 @@
     4.4     return 0;
     4.5     
     4.6     /* Error handling */
     4.7 -open_err:
     4.8 -   IDirectInputDevice_Release(device);
     4.9 -   goto creat_err;
    4.10  acquire_err:
    4.11     IDirectInputDevice2_Unacquire(haptic->hwdata->device);
    4.12  query_err:
    4.13 @@ -435,19 +432,11 @@
    4.14  void
    4.15  SDL_SYS_HapticClose(SDL_Haptic * haptic)
    4.16  {
    4.17 -   int i;
    4.18 -
    4.19     if (haptic->hwdata) {
    4.20  
    4.21 -      /* Free the effects. */
    4.22 -      for (i=0; i<haptic->neffects; i++) {        
    4.23 -         if (haptic->effects[i].hweffect != NULL) {
    4.24 -            SDL_SYS_HapticFreeFFEFFECT( &haptic->effects[i].hweffect->effect,
    4.25 -                                        haptic->effects[i].effect.type );
    4.26 -            SDL_free(haptic->effects[i].hweffect);
    4.27 -         } 
    4.28 -      }    
    4.29 +      /* Free effects. */
    4.30        SDL_free(haptic->effects);
    4.31 +      haptic->effects = NULL;
    4.32        haptic->neffects = 0;
    4.33  
    4.34        /* Clean up */