projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add type-checked versions of allocation and deallocations functions
[lttng-tools.git]
/
src
/
common
/
compat
/
poll.cpp
diff --git
a/src/common/compat/poll.cpp
b/src/common/compat/poll.cpp
index 928867ffb3f5a9ac5dffbe00d5dd905d89d5e07e..0617905a6ee65e37656956b650a41838cb9e1393 100644
(file)
--- a/
src/common/compat/poll.cpp
+++ b/
src/common/compat/poll.cpp
@@
-1,8
+1,8
@@
/*
/*
- * Copyright (C) 2011
David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2011
EfficiOS Inc.
* Copyright (C) 2019 Yannick Lamarre <ylamarre@efficios.com>
*
* Copyright (C) 2019 Yannick Lamarre <ylamarre@efficios.com>
*
- * SPDX-License-Identifier:
GPL-2.0
-only
+ * SPDX-License-Identifier:
LGPL-2.1
-only
*
*/
*
*/
@@
-10,14
+10,14
@@
#include <stdlib.h>
#include <stdbool.h>
#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.h
pp
>
+#include <common/error.h
pp
>
+#include <common/macros.h
pp
>
+#include <common/utils.h
pp
>
-#include "poll.h"
+#include "poll.h
pp
"
-#if HAVE_EPOLL
+#if
def
HAVE_EPOLL
#include <fcntl.h>
#include <limits.h>
#include <fcntl.h>
#include <limits.h>
@@
-71,11
+71,11
@@
error:
/*
* Create epoll set and allocate returned events structure.
*/
/*
* 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;
{
int ret;
- if (events == NULL ||
size
<= 0) {
+ if (events == NULL ||
count
<= 0) {
goto error;
}
goto error;
}
@@
-86,11
+86,11
@@
int compat_epoll_create(struct lttng_poll_event *events, int size, int flags)
}
/* Don't bust the limit here */
}
/* 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");
if (ret < 0) {
/* At this point, every error is fatal */
PERROR("epoll_create1");
@@
-100,13
+100,13
@@
int compat_epoll_create(struct lttng_poll_event *events, int size, int flags)
events->epfd = ret;
/* This *must* be freed by using lttng_poll_free() */
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;
}
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;
events->nb_fd = 0;
return 0;
@@
-374,7
+374,7
@@
static int resize_poll_event(struct compat_poll_event_array *array,
goto error;
}
goto error;
}
- ptr = realloc(array->events, new_size * sizeof(*ptr));
+ ptr =
(struct pollfd *)
realloc(array->events, new_size * sizeof(*ptr));
if (ptr == NULL) {
PERROR("realloc epoll add");
goto error;
if (ptr == NULL) {
PERROR("realloc epoll add");
goto error;
@@
-455,7
+455,7
@@
int compat_poll_create(struct lttng_poll_event *events, int size)
wait = &events->wait;
/* This *must* be freed by using lttng_poll_free() */
wait = &events->wait;
/* This *must* be freed by using lttng_poll_free() */
- wait->events = zmalloc(size * sizeof(struct pollfd));
+ wait->events =
(struct pollfd *)
zmalloc(size * sizeof(struct pollfd));
if (wait->events == NULL) {
PERROR("zmalloc struct pollfd");
goto error;
if (wait->events == NULL) {
PERROR("zmalloc struct pollfd");
goto error;
@@
-463,7
+463,7
@@
int compat_poll_create(struct lttng_poll_event *events, int size)
wait->alloc_size = wait->init_size = size;
wait->alloc_size = wait->init_size = size;
- current->events = zmalloc(size * sizeof(struct pollfd));
+ current->events =
(struct pollfd *)
zmalloc(size * sizeof(struct pollfd));
if (current->events == NULL) {
PERROR("zmalloc struct current pollfd");
goto error;
if (current->events == NULL) {
PERROR("zmalloc struct current pollfd");
goto error;
This page took
0.02582 seconds
and
4
git commands to generate.