From 76fcf15156ecb0a18f9c41b350342171f862ff47 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Tue, 28 Aug 2018 12:13:43 -0400 Subject: [PATCH] Hide lttng_event_copy symbol MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit lttng_event_copy()'s only caller is internal. It is hidden to reduce the API surface, but could be made public at some point to accomodate lttng-ctl users. Signed-off-by: Jérémie Galarneau --- include/lttng/event-internal.h | 6 ++++ include/lttng/event.h | 2 -- src/bin/lttng-sessiond/main.c | 1 + src/common/Makefile.am | 2 +- src/common/event.c | 52 ++++++++++++++++++++++++++++++++++ src/lib/lttng-ctl/event.c | 32 --------------------- 6 files changed, 60 insertions(+), 35 deletions(-) create mode 100644 src/common/event.c diff --git a/include/lttng/event-internal.h b/include/lttng/event-internal.h index 8902a1a08..f8130e3b9 100644 --- a/include/lttng/event-internal.h +++ b/include/lttng/event-internal.h @@ -22,6 +22,9 @@ #ifndef LTTNG_EVENT_INTERNAL_H #define LTTNG_EVENT_INTERNAL_H +#include +#include + struct lttng_userspace_probe_location; struct lttng_event_extended { @@ -40,4 +43,7 @@ struct lttng_event_extended { struct lttng_userspace_probe_location *probe_location; }; +LTTNG_HIDDEN +struct lttng_event *lttng_event_copy(const struct lttng_event *event); + #endif /* LTTNG_EVENT_INTERNAL_H */ diff --git a/include/lttng/event.h b/include/lttng/event.h index 2a02859a3..0f75245c9 100644 --- a/include/lttng/event.h +++ b/include/lttng/event.h @@ -321,8 +321,6 @@ extern int lttng_list_events(struct lttng_handle *handle, */ extern struct lttng_event *lttng_event_create(void); -extern struct lttng_event *lttng_event_copy(const struct lttng_event *event); - /* * Destroy an lttng_event. * diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index ee50db21e..bc3b49b71 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -51,6 +51,7 @@ #include #include #include +#include #include "lttng-sessiond.h" #include "buffer-registry.h" diff --git a/src/common/Makefile.am b/src/common/Makefile.am index d6a7da1d8..b9d344b88 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -27,7 +27,7 @@ libcommon_la_SOURCES = error.h error.c utils.c utils.h runas.h \ buffer-view.h buffer-view.c \ location.c \ waiter.h waiter.c \ - userspace-probe.c + userspace-probe.c event.c libcommon_la_LIBADD = \ $(top_builddir)/src/common/config/libconfig.la \ diff --git a/src/common/event.c b/src/common/event.c new file mode 100644 index 000000000..329a8688d --- /dev/null +++ b/src/common/event.c @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2018 - Jérémie Galarneau + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License, version 2.1 only, + * as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include + +LTTNG_HIDDEN +struct lttng_event *lttng_event_copy(const struct lttng_event *event) +{ + struct lttng_event *new_event; + struct lttng_event_extended *new_event_extended; + + new_event = zmalloc(sizeof(*event)); + if (!new_event) { + PERROR("Error allocating event structure"); + goto end; + } + + /* Copy the content of the old event. */ + memcpy(new_event, event, sizeof(*event)); + + /* + * We need to create a new extended since the previous pointer is now + * invalid. + */ + new_event_extended = zmalloc(sizeof(*new_event_extended)); + if (!new_event_extended) { + PERROR("Error allocating event extended structure"); + goto error; + } + + new_event->extended.ptr = new_event_extended; +end: + return new_event; +error: + free(new_event); + goto end; +} diff --git a/src/lib/lttng-ctl/event.c b/src/lib/lttng-ctl/event.c index 5785345cd..f8abf309e 100644 --- a/src/lib/lttng-ctl/event.c +++ b/src/lib/lttng-ctl/event.c @@ -54,38 +54,6 @@ error: goto end; } -struct lttng_event *lttng_event_copy(const struct lttng_event *event) -{ - struct lttng_event *new_event; - struct lttng_event_extended *new_event_extended; - - new_event = zmalloc(sizeof(*event)); - if (!new_event) { - PERROR("Error allocating event structure"); - goto end; - } - - /* Copy the content of the old event. */ - memcpy(new_event, event, sizeof(*event)); - - /* - * We need to create a new extended since the previous pointer is now - * invalid. - */ - new_event_extended = zmalloc(sizeof(*new_event_extended)); - if (!new_event_extended) { - PERROR("Error allocating event extended structure"); - goto error; - } - - new_event->extended.ptr = new_event_extended; -end: - return new_event; -error: - free(new_event); - goto end; -} - void lttng_event_destroy(struct lttng_event *event) { struct lttng_event_extended *event_extended; -- 2.34.1