Fix: lttng-destroy: missing newline on session destruction message
[lttng-tools.git] / src / common / event.c
1 /*
2 * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only
5 *
6 */
7
8 #include <lttng/event-internal.h>
9 #include <common/error.h>
10
11 LTTNG_HIDDEN
12 struct lttng_event *lttng_event_copy(const struct lttng_event *event)
13 {
14 struct lttng_event *new_event;
15 struct lttng_event_extended *new_event_extended;
16
17 new_event = zmalloc(sizeof(*event));
18 if (!new_event) {
19 PERROR("Error allocating event structure");
20 goto end;
21 }
22
23 /* Copy the content of the old event. */
24 memcpy(new_event, event, sizeof(*event));
25
26 /*
27 * We need to create a new extended since the previous pointer is now
28 * invalid.
29 */
30 new_event_extended = zmalloc(sizeof(*new_event_extended));
31 if (!new_event_extended) {
32 PERROR("Error allocating event extended structure");
33 goto error;
34 }
35
36 new_event->extended.ptr = new_event_extended;
37 end:
38 return new_event;
39 error:
40 free(new_event);
41 new_event = NULL;
42 goto end;
43 }
This page took 0.065534 seconds and 4 git commands to generate.