ef095554585c934569b04cf7da76f512d51f195d
2 * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
10 #include <common/dynamic-array.hpp>
11 #include <common/dynamic-buffer.hpp>
12 #include <common/error.hpp>
14 static 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
, release_fd_handle_ref
);
28 int lttng_payload_copy(const struct lttng_payload
*src_payload
, struct lttng_payload
*dst_payload
)
33 ret
= lttng_dynamic_buffer_append_buffer(&dst_payload
->buffer
, &src_payload
->buffer
);
38 for (i
= 0; i
< lttng_dynamic_pointer_array_get_count(&src_payload
->_fd_handles
); i
++) {
39 struct fd_handle
*new_fd_handle
;
40 const struct fd_handle
*src_fd_handle
=
41 (fd_handle
*) lttng_dynamic_pointer_array_get_pointer(
42 &src_payload
->_fd_handles
, i
);
44 new_fd_handle
= fd_handle_copy(src_fd_handle
);
46 PERROR("Failed to copy fd_handle while copying a payload");
51 ret
= lttng_payload_push_fd_handle(dst_payload
, new_fd_handle
);
52 fd_handle_put(new_fd_handle
);
62 void lttng_payload_reset(struct lttng_payload
*payload
)
68 lttng_dynamic_buffer_reset(&payload
->buffer
);
69 lttng_dynamic_pointer_array_reset(&payload
->_fd_handles
);
72 void lttng_payload_clear(struct lttng_payload
*payload
)
74 (void) lttng_dynamic_buffer_set_size(&payload
->buffer
, 0);
75 lttng_dynamic_pointer_array_clear(&payload
->_fd_handles
);
78 int lttng_payload_push_fd_handle(struct lttng_payload
*payload
, struct fd_handle
*fd_handle
)
87 ret
= lttng_dynamic_pointer_array_add_pointer(&payload
->_fd_handles
, fd_handle
);
92 fd_handle_get(fd_handle
);
This page took 0.036536 seconds and 5 git commands to generate.