Zero out haptic linked list items on creation
authorGabriel Jacobo <gabomdq@gmail.com>
Mon, 24 Feb 2014 10:25:02 -0300
changeset 8247 fd220c4df418
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
--- a/src/haptic/darwin/SDL_syshaptic.c	Mon Feb 24 10:00:10 2014 -0300
+++ b/src/haptic/darwin/SDL_syshaptic.c	Mon Feb 24 10:25:02 2014 -0300
@@ -237,7 +237,7 @@
         }
     }
 
-    item = (SDL_hapticlist_item *)SDL_malloc( sizeof(SDL_hapticlist_item));
+    item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item));
     if (item == NULL) {
         return SDL_SetError("Could not allocate haptic storage");
     }
@@ -248,7 +248,6 @@
     /* Set basic device data. */
     HIDGetDeviceProduct(device, item->name);
     item->dev = device;
-    item->haptic = NULL;
 
     /* Set usage pages. */
     hidProperties = 0;
--- a/src/haptic/linux/SDL_syshaptic.c	Mon Feb 24 10:00:10 2014 -0300
+++ b/src/haptic/linux/SDL_syshaptic.c	Mon Feb 24 10:25:02 2014 -0300
@@ -282,11 +282,11 @@
         return -1;
     }
 
-    item = (SDL_hapticlist_item *) SDL_malloc(sizeof (SDL_hapticlist_item));
+    item = (SDL_hapticlist_item *) SDL_calloc(1, sizeof (SDL_hapticlist_item));
     if (item == NULL) {
         return -1;
     }
-    SDL_zerop(item);
+
     item->fname = SDL_strdup(path);
     if ( (item->fname == NULL) ) {
         SDL_free(item->fname);
--- a/src/haptic/windows/SDL_syshaptic.c	Mon Feb 24 10:00:10 2014 -0300
+++ b/src/haptic/windows/SDL_syshaptic.c	Mon Feb 24 10:25:02 2014 -0300
@@ -253,13 +253,11 @@
         return -1;  /* not a device we can use. */
     }
 
-    item = (SDL_hapticlist_item *)SDL_malloc( sizeof(SDL_hapticlist_item));
+    item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item));
     if (item == NULL) {
         return SDL_OutOfMemory();
     }
 
-    SDL_zerop(item);
-
     item->name = WIN_StringToUTF8(pdidInstance->tszProductName);
     if (!item->name) {
         SDL_free(item);