mirror of
https://gitlab.freedesktop.org/libevdev/libevdev.git
synced 2025-12-24 06:30:05 +01:00
Let the name be dynamically allocated
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
4318b73549
commit
46b829a4f2
2 changed files with 11 additions and 2 deletions
|
|
@ -52,7 +52,7 @@ struct libevdev {
|
|||
int fd;
|
||||
libevdev_log_func_t log;
|
||||
|
||||
char name[MAX_NAME];
|
||||
char *name;
|
||||
char *phys;
|
||||
char *uniq;
|
||||
struct input_id ids;
|
||||
|
|
|
|||
|
|
@ -180,6 +180,7 @@ libevdev_new_from_fd(int fd, struct libevdev **dev)
|
|||
void
|
||||
libevdev_free(struct libevdev *dev)
|
||||
{
|
||||
free(dev->name);
|
||||
free(dev->phys);
|
||||
free(dev->uniq);
|
||||
queue_free(dev);
|
||||
|
|
@ -215,10 +216,18 @@ libevdev_set_fd(struct libevdev* dev, int fd)
|
|||
if (rc < 0)
|
||||
goto out;
|
||||
|
||||
rc = ioctl(fd, EVIOCGNAME(sizeof(dev->name) - 1), dev->name);
|
||||
memset(buf, 0, sizeof(buf));
|
||||
rc = ioctl(fd, EVIOCGNAME(sizeof(buf) - 1), buf);
|
||||
if (rc < 0)
|
||||
goto out;
|
||||
|
||||
dev->name = calloc(strlen(buf) + 1, sizeof(char));
|
||||
if (!dev->name) {
|
||||
errno = ENOSPC;
|
||||
goto out;
|
||||
}
|
||||
strcpy(dev->name, buf);
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
rc = ioctl(fd, EVIOCGPHYS(sizeof(buf) - 1), buf);
|
||||
if (rc < 0) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue