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"
14 bool lttng_payload_view_is_valid(const struct lttng_payload_view
*view
)
16 return view
&& lttng_buffer_view_is_valid(&view
->buffer
);
19 struct lttng_payload_view
lttng_payload_view_from_payload(
20 const struct lttng_payload
*payload
, size_t offset
,
23 return payload
? (struct lttng_payload_view
) {
24 .buffer
= lttng_buffer_view_from_dynamic_buffer(
25 &payload
->buffer
, offset
, len
),
26 ._fd_handles
= payload
->_fd_handles
,
27 } : (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
,
42 .p_fd_handles_position
= view
->_iterator
.p_fd_handles_position
?:
43 &view
->_iterator
.fd_handles_position
,
45 } : (struct lttng_payload_view
) {
51 struct lttng_payload_view
lttng_payload_view_from_dynamic_buffer(
52 const struct lttng_dynamic_buffer
*buffer
, size_t offset
,
55 return buffer
? (struct lttng_payload_view
) {
56 .buffer
= lttng_buffer_view_from_dynamic_buffer(
59 } : (struct lttng_payload_view
) {
65 struct lttng_payload_view
lttng_payload_view_from_buffer_view(
66 const struct lttng_buffer_view
*view
, size_t offset
,
69 return view
? (struct lttng_payload_view
) {
70 .buffer
= lttng_buffer_view_from_view(
73 } : (struct lttng_payload_view
) {
79 struct lttng_payload_view
lttng_payload_view_init_from_buffer(
80 const char *src
, size_t offset
, ptrdiff_t len
)
82 return (struct lttng_payload_view
) {
83 .buffer
= lttng_buffer_view_init(
89 int lttng_payload_view_get_fd_handle_count(
90 const struct lttng_payload_view
*payload_view
)
100 ret
= lttng_dynamic_pointer_array_get_count(&payload_view
->_fd_handles
);
105 position
= payload_view
->_iterator
.p_fd_handles_position
?
106 *payload_view
->_iterator
.p_fd_handles_position
:
107 payload_view
->_iterator
.fd_handles_position
;
108 ret
= ret
- (int) position
;
113 struct fd_handle
*lttng_payload_view_pop_fd_handle(
114 struct lttng_payload_view
*view
)
116 struct fd_handle
*handle
= NULL
;
117 size_t fd_handle_count
;
124 fd_handle_count
= lttng_payload_view_get_fd_handle_count(view
);
125 if (fd_handle_count
== 0) {
129 pos
= view
->_iterator
.p_fd_handles_position
?
130 view
->_iterator
.p_fd_handles_position
:
131 &view
->_iterator
.fd_handles_position
;
132 handle
= (fd_handle
*) lttng_dynamic_pointer_array_get_pointer(&view
->_fd_handles
,
135 fd_handle_get(handle
);
This page took 0.032178 seconds and 4 git commands to generate.