2 * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
9 #include <common/dynamic-array.hpp>
10 #include <common/dynamic-buffer.hpp>
11 #include <common/error.hpp>
14 void release_fd_handle_ref(void *ptr
)
16 struct fd_handle
*fd_handle
= (struct fd_handle
*) ptr
;
18 fd_handle_put(fd_handle
);
21 void lttng_payload_init(struct lttng_payload
*payload
)
23 LTTNG_ASSERT(payload
);
24 lttng_dynamic_buffer_init(&payload
->buffer
);
25 lttng_dynamic_pointer_array_init(&payload
->_fd_handles
,
26 release_fd_handle_ref
);
29 int lttng_payload_copy(const struct lttng_payload
*src_payload
,
30 struct lttng_payload
*dst_payload
)
35 ret
= lttng_dynamic_buffer_append_buffer(
36 &dst_payload
->buffer
, &src_payload
->buffer
);
41 for (i
= 0; i
< lttng_dynamic_pointer_array_get_count(
42 &src_payload
->_fd_handles
);
44 struct fd_handle
*new_fd_handle
;
45 const struct fd_handle
*src_fd_handle
=
46 (fd_handle
*) lttng_dynamic_pointer_array_get_pointer(
47 &src_payload
->_fd_handles
, i
);
49 new_fd_handle
= fd_handle_copy(src_fd_handle
);
51 PERROR("Failed to copy fd_handle while copying a payload");
56 ret
= lttng_payload_push_fd_handle(dst_payload
, new_fd_handle
);
57 fd_handle_put(new_fd_handle
);
67 void lttng_payload_reset(struct lttng_payload
*payload
)
73 lttng_dynamic_buffer_reset(&payload
->buffer
);
74 lttng_dynamic_pointer_array_reset(&payload
->_fd_handles
);
77 void lttng_payload_clear(struct lttng_payload
*payload
)
79 (void) lttng_dynamic_buffer_set_size(&payload
->buffer
, 0);
80 lttng_dynamic_pointer_array_clear(&payload
->_fd_handles
);
83 int lttng_payload_push_fd_handle(struct lttng_payload
*payload
,
84 struct fd_handle
*fd_handle
)
93 ret
= lttng_dynamic_pointer_array_add_pointer(
94 &payload
->_fd_handles
, fd_handle
);
99 fd_handle_get(fd_handle
);
This page took 0.033754 seconds and 4 git commands to generate.