On the typical setup we have at least 3 events pending as soon as we hook it
up (seat added, device added, capability). In the udev case we get up to > 64
events without even having input events on my laptop with only two extra
devices connected. So always allocate an event buffer to avoid spurious
resizing.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
if (libinput->epoll_fd < 0)
return -1;
+ libinput->events_len = 4;
+ libinput->events = zalloc(libinput->events_len * sizeof(*libinput->events));
+ if (!libinput->events) {
+ close(libinput->epoll_fd);
+ return -1;
+ }
+
libinput->interface = interface;
libinput->user_data = user_data;
list_init(&libinput->source_destroy_list);
events_count++;
if (events_count > events_len) {
- if (events_len == 0)
- events_len = 4;
- else
- events_len *= 2;
+ events_len *= 2;
events = realloc(events, events_len * sizeof *events);
if (!events) {
fprintf(stderr, "Failed to reallocate event ring "