consumerd: cleanup: use buffer view interface for mmap read subbuf
[lttng-tools.git] / src / common / event.c
CommitLineData
76fcf151 1/*
ab5be9fa 2 * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
76fcf151 3 *
ab5be9fa 4 * SPDX-License-Identifier: LGPL-2.1-only
76fcf151 5 *
76fcf151
JG
6 */
7
8#include <lttng/event-internal.h>
9#include <common/error.h>
10
11LTTNG_HIDDEN
12struct 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;
37end:
38 return new_event;
39error:
40 free(new_event);
37750a61 41 new_event = NULL;
76fcf151
JG
42 goto end;
43}
This page took 0.031089 seconds and 4 git commands to generate.