Zero out haptic linked list items on creation
authorGabriel Jacobo <gabomdq@gmail.com>
Mon, 24 Feb 2014 10:25:02 -0300
changeset 8247fd220c4df418
parent 8246 e55dadcb9155
child 8248 427d0a6f5af7
Zero out haptic linked list items on creation

(thanks to Turo Lamminen for the report!)
src/haptic/darwin/SDL_syshaptic.c
src/haptic/linux/SDL_syshaptic.c
src/haptic/windows/SDL_syshaptic.c
     1.1 --- a/src/haptic/darwin/SDL_syshaptic.c	Mon Feb 24 10:00:10 2014 -0300
     1.2 +++ b/src/haptic/darwin/SDL_syshaptic.c	Mon Feb 24 10:25:02 2014 -0300
     1.3 @@ -237,7 +237,7 @@
     1.4          }
     1.5      }
     1.6  
     1.7 -    item = (SDL_hapticlist_item *)SDL_malloc( sizeof(SDL_hapticlist_item));
     1.8 +    item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item));
     1.9      if (item == NULL) {
    1.10          return SDL_SetError("Could not allocate haptic storage");
    1.11      }
    1.12 @@ -248,7 +248,6 @@
    1.13      /* Set basic device data. */
    1.14      HIDGetDeviceProduct(device, item->name);
    1.15      item->dev = device;
    1.16 -    item->haptic = NULL;
    1.17  
    1.18      /* Set usage pages. */
    1.19      hidProperties = 0;
     2.1 --- a/src/haptic/linux/SDL_syshaptic.c	Mon Feb 24 10:00:10 2014 -0300
     2.2 +++ b/src/haptic/linux/SDL_syshaptic.c	Mon Feb 24 10:25:02 2014 -0300
     2.3 @@ -282,11 +282,11 @@
     2.4          return -1;
     2.5      }
     2.6  
     2.7 -    item = (SDL_hapticlist_item *) SDL_malloc(sizeof (SDL_hapticlist_item));
     2.8 +    item = (SDL_hapticlist_item *) SDL_calloc(1, sizeof (SDL_hapticlist_item));
     2.9      if (item == NULL) {
    2.10          return -1;
    2.11      }
    2.12 -    SDL_zerop(item);
    2.13 +
    2.14      item->fname = SDL_strdup(path);
    2.15      if ( (item->fname == NULL) ) {
    2.16          SDL_free(item->fname);
     3.1 --- a/src/haptic/windows/SDL_syshaptic.c	Mon Feb 24 10:00:10 2014 -0300
     3.2 +++ b/src/haptic/windows/SDL_syshaptic.c	Mon Feb 24 10:25:02 2014 -0300
     3.3 @@ -253,13 +253,11 @@
     3.4          return -1;  /* not a device we can use. */
     3.5      }
     3.6  
     3.7 -    item = (SDL_hapticlist_item *)SDL_malloc( sizeof(SDL_hapticlist_item));
     3.8 +    item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item));
     3.9      if (item == NULL) {
    3.10          return SDL_OutOfMemory();
    3.11      }
    3.12  
    3.13 -    SDL_zerop(item);
    3.14 -
    3.15      item->name = WIN_StringToUTF8(pdidInstance->tszProductName);
    3.16      if (!item->name) {
    3.17          SDL_free(item);