2 * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
8 #include <common/dynamic-array.h>
9 #include <common/buffer-view.h>
10 #include "payload-view.h"
15 bool lttng_payload_view_is_valid(const struct lttng_payload_view
*view
)
17 return view
&& lttng_buffer_view_is_valid(&view
->buffer
);
21 struct lttng_payload_view
lttng_payload_view_from_payload(
22 const struct lttng_payload
*payload
, size_t offset
,
25 return payload
? (struct lttng_payload_view
) {
26 .buffer
= lttng_buffer_view_from_dynamic_buffer(
27 &payload
->buffer
, offset
, len
),
28 ._fd_handles
= payload
->_fd_handles
,
29 } : (struct lttng_payload_view
) {};
33 struct lttng_payload_view
lttng_payload_view_from_view(
34 struct lttng_payload_view
*view
, size_t offset
,
37 return view
? (struct lttng_payload_view
) {
38 .buffer
= lttng_buffer_view_from_view(
39 &view
->buffer
, offset
, len
),
40 ._fd_handles
= view
->_fd_handles
,
41 ._iterator
.p_fd_handles_position
= view
->_iterator
.p_fd_handles_position
?:
42 &view
->_iterator
.fd_handles_position
,
43 } : (struct lttng_payload_view
) {};
47 struct lttng_payload_view
lttng_payload_view_from_dynamic_buffer(
48 const struct lttng_dynamic_buffer
*buffer
, size_t offset
,
51 return buffer
? (struct lttng_payload_view
) {
52 .buffer
= lttng_buffer_view_from_dynamic_buffer(
54 } : (struct lttng_payload_view
) {};
58 struct lttng_payload_view
lttng_payload_view_from_buffer_view(
59 const struct lttng_buffer_view
*view
, size_t offset
,
62 return view
? (struct lttng_payload_view
) {
63 .buffer
= lttng_buffer_view_from_view(
65 } : (struct lttng_payload_view
) {};
69 struct lttng_payload_view
lttng_payload_view_init_from_buffer(
70 const char *src
, size_t offset
, ptrdiff_t len
)
72 return (struct lttng_payload_view
) {
73 .buffer
= lttng_buffer_view_init(
79 int lttng_payload_view_get_fd_handle_count(
80 const struct lttng_payload_view
*payload_view
)
90 ret
= lttng_dynamic_pointer_array_get_count(&payload_view
->_fd_handles
);
95 position
= payload_view
->_iterator
.p_fd_handles_position
?
96 *payload_view
->_iterator
.p_fd_handles_position
:
97 payload_view
->_iterator
.fd_handles_position
;
98 ret
= ret
- (int) position
;
104 struct fd_handle
*lttng_payload_view_pop_fd_handle(
105 struct lttng_payload_view
*view
)
107 struct fd_handle
*handle
= NULL
;
108 size_t fd_handle_count
;
115 fd_handle_count
= lttng_payload_view_get_fd_handle_count(view
);
116 if (fd_handle_count
== 0) {
120 pos
= view
->_iterator
.p_fd_handles_position
?
121 view
->_iterator
.p_fd_handles_position
:
122 &view
->_iterator
.fd_handles_position
;
123 handle
= lttng_dynamic_pointer_array_get_pointer(&view
->_fd_handles
,
126 fd_handle_get(handle
);
This page took 0.034486 seconds and 5 git commands to generate.