2 * Copyright (C) 2017 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License, version 2.1 only,
6 * as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program; if not, write to the Free Software Foundation,
15 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 #ifndef LTTNG_DYNAMIC_BUFFER_H
19 #define LTTNG_DYNAMIC_BUFFER_H
24 struct lttng_dynamic_buffer
{
30 void lttng_dynamic_buffer_init(struct lttng_dynamic_buffer
*buffer
);
32 int lttng_dynamic_buffer_append(struct lttng_dynamic_buffer
*buffer
,
33 const void *buf
, size_t len
);
35 int lttng_dynamic_buffer_append_buffer(struct lttng_dynamic_buffer
*dst_buffer
,
36 struct lttng_dynamic_buffer
*src_buffer
);
39 * Set the buffer's size to new_size. The capacity of the buffer will
40 * be expanded (if necessary) to accomodate new_size. Areas acquired by
41 * an enlarging new_size _will be zeroed_.
43 * Be careful to expand the buffer's size _before_ calling out external
44 * APIs (e.g. read(3)) which may populate the buffer as setting the size
45 * _after_ will zero-out the result of the operation.
47 int lttng_dynamic_buffer_set_size(struct lttng_dynamic_buffer
*buffer
,
51 * Set the buffer's capacity to accomodate the new_capacity, allocating memory
52 * as necessary. The buffer's content is preserved.
54 * If the current size > new_capacity, the operation will fail.
56 int lttng_dynamic_buffer_set_capacity(struct lttng_dynamic_buffer
*buffer
,
59 /* Release any memory used by the dynamic buffer. */
60 void lttng_dynamic_buffer_reset(struct lttng_dynamic_buffer
*buffer
);
62 #endif /* LTTNG_DYNAMIC_BUFFER_H */
This page took 0.032484 seconds and 5 git commands to generate.