[PATCH xf86-input-joystick 1/2] Deprecated code cleanup.

walter harms wharms at bfs.de
Tue Oct 19 01:07:23 PDT 2010



Peter Hutterer schrieb:
> On Sun, Oct 17, 2010 at 09:25:56PM -0400, Trevor Woerner wrote:
>> From: Trevor Woerner <twoerner at gmail.com>
>>
>> Replace calls to deprecated functions (Xfree(), Xcalloc(), Xmalloc(), etc)
>> with calls to standard dynamic memory functions (free(), calloc(), malloc(),
>> etc) in driver code.
>>
>> Signed-off-by: Trevor Woerner <twoerner at gmail.com>
> 
> both patches pushed, thanks.
> 
> Cheers,
>   Peter
> 
>> ---
>>  src/jstk.c         |    8 ++++----
>>  src/jstk_key.c     |    8 ++++----
>>  src/jstk_options.c |    4 ++--
>>  3 files changed, 10 insertions(+), 10 deletions(-)
>>
>> diff --git a/src/jstk.c b/src/jstk.c
>> index 95fb093..fbfe905 100644
>> --- a/src/jstk.c
>> +++ b/src/jstk.c
>> @@ -524,7 +524,7 @@ jstkCorePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
>>          goto SetupProc_fail;
>>      }
>>  
>> -    local->private = (JoystickDevPtr)xalloc(sizeof(JoystickDevRec));
>> +    local->private = (JoystickDevPtr)malloc(sizeof(JoystickDevRec));

malloc will return (void *) so there is no need to cast.
i do not know xmalloc() but i see no check for OOM condition.
instead of removing xmalloc() it would be more useful to follow
XtMalloc() that has error handling inside.



>>      priv = (JoystickDevPtr)local->private;
>>  
>>      local->name   = dev->identifier;
>> @@ -657,7 +657,7 @@ jstkCorePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
>>              DBG(1, xf86Msg(X_CONFIG, "Autorepeat set to delay=%d, interval=%d\n",
>>                             priv->repeat_delay,priv->repeat_interval));
>>          }
>> -        xfree(s);
>> +        free(s);
>>      }
>>      
>>      priv->rmlvo.rules = xf86SetStrOption(dev->commonOptions, "xkb_rules", NULL);
>> @@ -722,7 +722,7 @@ jstkCorePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
>>  
>>  SetupProc_fail:
>>      if (priv)
>> -        xfree(priv);
>> +        free(priv);
>>      if (local)
>>          local->private = NULL;
>>      return NULL;
>> @@ -754,7 +754,7 @@ jstkCoreUnInit(InputDriverPtr    drv,
>>          device->keyboard_device = NULL;
>>      }
>>  
>> -    xfree (device);
>> +    free (device);
>>      local->private = NULL;
>>      xf86DeleteInput(local, 0);
>>  }
>> diff --git a/src/jstk_key.c b/src/jstk_key.c
>> index c841cf0..35b8928 100644
>> --- a/src/jstk_key.c
>> +++ b/src/jstk_key.c
>> @@ -506,7 +506,7 @@ jstkKeyboardPreInit(InputDriverPtr drv, IDevPtr _dev, int flags)
>>          goto SetupProc_fail;
>>      }
>>  
>> -    dev = xcalloc(sizeof(IDevRec), 1);
>> +    dev = calloc(sizeof(IDevRec), 1);
>>      strcpy(name, _dev->identifier);
>>      strcat(name, " (keys)");
>>      dev->identifier = xstrdup(name);
>> @@ -544,9 +544,9 @@ SetupProc_fail:
>>      if (local)
>>          local->private = NULL;
>>      if (dev) {
>> -        if (dev->identifier) xfree(dev->identifier);
>> -        if (dev->driver) xfree(dev->driver);
>> -        xfree(dev);
>> +        if (dev->identifier) free(dev->identifier);
>> +        if (dev->driver) free(dev->driver);
>> +        free(dev);

The is no need to check dev->identifier since free() can handle free(NULL)



>>      }
>>      return NULL;
>>  }
>> diff --git a/src/jstk_options.c b/src/jstk_options.c
>> index 4ce9d36..65f25f8 100644
>> --- a/src/jstk_options.c
>> +++ b/src/jstk_options.c
>> @@ -155,7 +155,7 @@ jstkParseButtonOption(const char* org,
>>          xf86Msg(X_WARNING, "%s: error parsing button parameter.\n", 
>>                  name);
>>      }
>> -    xfree(param);
>> +    free(param);
>>  }
>>  
>>  
>> @@ -293,5 +293,5 @@ jstkParseAxisOption(const char* org,
>>          }else xf86Msg(X_WARNING, "%s: error parsing deadzone.\n", 
>>                        name);
>>      }
>> -    xfree(param);
>> +    free(param);
>>  }
>> -- 
>> 1.7.3.1.120.g38a18
>>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
> 


More information about the xorg-devel mailing list