+/*
+ * Resize the epoll events structure of the new size.
+ *
+ * Return 0 on success or else -1 with the current events pointer untouched.
+ */
+static int resize_poll_event(struct lttng_poll_event *events,
+ uint32_t new_size)
+{
+ struct epoll_event *ptr;
+
+ assert(events);
+
+ ptr = realloc(events->events, new_size * sizeof(*ptr));
+ if (ptr == NULL) {
+ PERROR("realloc epoll add");
+ goto error;
+ }
+ if (new_size > events->alloc_size) {
+ /* Zero newly allocated memory */
+ memset(ptr + events->alloc_size, 0,
+ (new_size - events->alloc_size) * sizeof(*ptr));
+ }
+ events->events = ptr;
+ events->alloc_size = new_size;
+
+ return 0;
+
+error:
+ return -1;
+}
+