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.h>
10 #include <common/dynamic-buffer.h>
11 #include <common/error.h>
14 void release_fd_handle_ref(void *ptr
)
16 struct fd_handle
*fd_handle
= ptr
;
18 fd_handle_put(fd_handle
);
22 void lttng_payload_init(struct lttng_payload
*payload
)
25 lttng_dynamic_buffer_init(&payload
->buffer
);
26 lttng_dynamic_pointer_array_init(&payload
->_fd_handles
,
27 release_fd_handle_ref
);
31 int lttng_payload_copy(const struct lttng_payload
*src_payload
,
32 struct lttng_payload
*dst_payload
)
37 ret
= lttng_dynamic_buffer_append_buffer(
38 &dst_payload
->buffer
, &src_payload
->buffer
);
43 for (i
= 0; i
< lttng_dynamic_pointer_array_get_count(
44 &src_payload
->_fd_handles
);
46 struct fd_handle
*new_fd_handle
;
47 const struct fd_handle
*src_fd_handle
=
48 lttng_dynamic_pointer_array_get_pointer(
49 &src_payload
->_fd_handles
, i
);
51 new_fd_handle
= fd_handle_copy(src_fd_handle
);
53 PERROR("Failed to copy fd_handle while copying a payload");
58 ret
= lttng_payload_push_fd_handle(dst_payload
, new_fd_handle
);
59 fd_handle_put(new_fd_handle
);
70 void lttng_payload_reset(struct lttng_payload
*payload
)
76 lttng_dynamic_buffer_reset(&payload
->buffer
);
77 lttng_dynamic_pointer_array_reset(&payload
->_fd_handles
);
81 void lttng_payload_clear(struct lttng_payload
*payload
)
83 (void) lttng_dynamic_buffer_set_size(&payload
->buffer
, 0);
84 lttng_dynamic_pointer_array_clear(&payload
->_fd_handles
);
88 int lttng_payload_push_fd_handle(struct lttng_payload
*payload
,
89 struct fd_handle
*fd_handle
)
98 ret
= lttng_dynamic_pointer_array_add_pointer(
99 &payload
->_fd_handles
, fd_handle
);
104 fd_handle_get(fd_handle
);
This page took 0.030787 seconds and 4 git commands to generate.