liblttng-ctl: use lttng_payload for serialize/create_from_buffer
[lttng-tools.git] / src / common / sessiond-comm / payload.c
1 /*
2 * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only
5 *
6 */
7
8 #include "payload.h"
9
10 LTTNG_HIDDEN
11 void lttng_payload_init(struct lttng_payload *payload)
12 {
13 assert(payload);
14 lttng_dynamic_buffer_init(&payload->buffer);
15 lttng_dynamic_array_init(&payload->_fds, sizeof(int), NULL);
16 }
17
18 LTTNG_HIDDEN
19 void lttng_payload_reset(struct lttng_payload *payload)
20 {
21 if (!payload) {
22 return;
23 }
24
25 lttng_dynamic_buffer_reset(&payload->buffer);
26 lttng_dynamic_array_reset(&payload->_fds);
27 }
28
29 LTTNG_HIDDEN
30 int lttng_payload_push_fd(struct lttng_payload *payload, int fd)
31 {
32 int ret;
33
34 if (!payload) {
35 ret = -1;
36 goto end;
37 }
38
39 ret = lttng_dynamic_array_add_element(&payload->_fds, &fd);
40 end:
41 return ret;
42 }
This page took 0.041381 seconds and 4 git commands to generate.