* Copyright (C) 2011 EfficiOS Inc.
* Copyright (C) 2019 Yannick Lamarre <ylamarre@efficios.com>
*
- * SPDX-License-Identifier: GPL-2.0-only
+ * SPDX-License-Identifier: LGPL-2.1-only
*
*/
#include <stdlib.h>
#include <stdbool.h>
-#include <common/defaults.h>
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/utils.h>
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/utils.hpp>
-#include "poll.h"
+#include "poll.hpp"
-#if HAVE_EPOLL
+#ifdef HAVE_EPOLL
#include <fcntl.h>
#include <limits.h>
/*
* Create epoll set and allocate returned events structure.
*/
-int compat_epoll_create(struct lttng_poll_event *events, int size, int flags)
+int compat_epoll_create(struct lttng_poll_event *events, int count, int flags)
{
int ret;
- if (events == NULL || size <= 0) {
+ if (events == NULL || count <= 0) {
goto error;
}
}
/* Don't bust the limit here */
- if (size > poll_max_size) {
- size = poll_max_size;
+ if (count > poll_max_size) {
+ count = poll_max_size;
}
- ret = compat_glibc_epoll_create(size, flags);
+ ret = compat_glibc_epoll_create(count, flags);
if (ret < 0) {
/* At this point, every error is fatal */
PERROR("epoll_create1");
events->epfd = ret;
/* This *must* be freed by using lttng_poll_free() */
- events->events = (epoll_event *) zmalloc(size * sizeof(struct epoll_event));
+ events->events = calloc<epoll_event>(count);
if (events->events == NULL) {
PERROR("zmalloc epoll set");
goto error_close;
}
- events->alloc_size = events->init_size = size;
+ events->alloc_size = events->init_size = count;
events->nb_fd = 0;
return 0;