2 * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
8 #ifndef LTTNG_BUFFER_VIEW_H
9 #define LTTNG_BUFFER_VIEW_H
11 #include <common/macros.h>
20 struct lttng_dynamic_buffer
;
22 struct lttng_buffer_view
{
28 * Return a buffer view referencing a subset of the memory referenced by a raw
31 * @src Source buffer to reference
32 * @offset Offset to apply to the source memory buffer
33 * @len Length of the memory contents to reference.
35 * Note that a buffer view never assumes the ownership of the memory it
38 struct lttng_buffer_view
lttng_buffer_view_init(
39 const char *src
, size_t offset
, ptrdiff_t len
);
42 * Checks if a buffer view is safe to access.
44 * After calling the buffer view creation functions, callers should verify
45 * if the resquested length (if any is explicitly provided) could be mapped
48 * @view Buffer view to validate
50 bool lttng_buffer_view_is_valid(const struct lttng_buffer_view
*view
);
53 * Return a buffer view referencing a subset of the memory referenced by another
56 * @src Source view to reference
57 * @offset Offset to apply to the source memory content
58 * @len Length of the memory contents to reference. Passing -1 will
59 * cause the view to reference the whole view from the offset
62 * Note that a buffer view never assumes the ownership of the memory it
65 struct lttng_buffer_view
lttng_buffer_view_from_view(
66 const struct lttng_buffer_view
*src
, size_t offset
,
70 * Return a buffer view referencing a subset of the memory referenced by a
73 * @src Source dynamic buffer to reference
74 * @offset Offset to apply to the source memory content
75 * @len Length of the memory contents to reference. Passing -1 will
76 * cause the view to reference the whole dynamic buffer from the
79 * Note that a buffer view never assumes the ownership of the memory it
82 struct lttng_buffer_view
lttng_buffer_view_from_dynamic_buffer(
83 const struct lttng_dynamic_buffer
*src
, size_t offset
,
87 * Verify that `buf` contains a string starting at `str` of length
88 * `len_with_null_terminator`.
90 * @buf The buffer view
91 * @str The start of the string
92 * @len_with_null_terminator Expected length of the string, including the
95 bool lttng_buffer_view_contains_string(const struct lttng_buffer_view
*buf
,
97 size_t len_with_null_terminator
);
103 #endif /* LTTNG_BUFFER_VIEW_H */
This page took 0.034924 seconds and 6 git commands to generate.