diff options
| author | Peter Hutterer <peter.hutterer@who-t.net> | 2013-06-27 09:45:58 +1000 |
|---|---|---|
| committer | Peter Hutterer <peter.hutterer@who-t.net> | 2013-06-27 10:41:54 +1000 |
| commit | 51244538b59143adff6d67befa6ed71c14b7987c (patch) | |
| tree | f13b809dfa9eda49452efe872f9e3a04f3335b09 /libevdev/libevdev.c | |
| parent | 9b7cc815ea3d944344f1f24c0221dfa25d0da0ac (diff) | |
| download | libevdev-51244538b59143adff6d67befa6ed71c14b7987c.tar.gz | |
Replace a few malloc + strcpy with strdup
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'libevdev/libevdev.c')
| -rw-r--r-- | libevdev/libevdev.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/libevdev/libevdev.c b/libevdev/libevdev.c index 7fefa0d..2ba2155 100644 --- a/libevdev/libevdev.c +++ b/libevdev/libevdev.c @@ -145,12 +145,11 @@ libevdev_set_fd(struct libevdev* dev, int fd) if (rc < 0) goto out; - dev->name = calloc(strlen(buf) + 1, sizeof(char)); + dev->name = strdup(buf); if (!dev->name) { errno = ENOSPC; goto out; } - strcpy(dev->name, buf); memset(buf, 0, sizeof(buf)); rc = ioctl(fd, EVIOCGPHYS(sizeof(buf) - 1), buf); @@ -159,12 +158,11 @@ libevdev_set_fd(struct libevdev* dev, int fd) if (errno != ENOENT) goto out; } else { - dev->phys = calloc(strlen(buf) + 1, sizeof(char)); + dev->phys = strdup(buf); if (!dev->phys) { errno = ENOSPC; goto out; } - strcpy(dev->phys, buf); } memset(buf, 0, sizeof(buf)); @@ -173,12 +171,11 @@ libevdev_set_fd(struct libevdev* dev, int fd) if (errno != ENOENT) goto out; } else { - dev->uniq = calloc(strlen(buf) + 1, sizeof(char)); + dev->uniq = strdup(buf); if (!dev->uniq) { errno = ENOSPC; goto out; } - strcpy(dev->uniq, buf); } rc = ioctl(fd, EVIOCGID, &dev->ids); |
