Fix: lttng: uninitialized pointer free'd when no sessiond is present
[lttng-tools.git] / include / lttng / tracker-internal.h
CommitLineData
2d97a006 1/*
ab5be9fa 2 * Copyright (C) 2019 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
2d97a006 3 *
ab5be9fa 4 * SPDX-License-Identifier: LGPL-2.1-only
2d97a006 5 *
2d97a006
JR
6 */
7
8#ifndef LTTNG_TRACKER_INTERNAL_H
9#define LTTNG_TRACKER_INTERNAL_H
10
2d97a006 11#include <common/macros.h>
f19f5c96
JR
12#include <common/dynamic-buffer.h>
13#include <lttng/constant.h>
2d97a006
JR
14#include <lttng/tracker.h>
15#include <stdbool.h>
16
17struct lttng_tracker_id {
18 enum lttng_tracker_id_type type;
19 int value;
20 char *string;
21};
22
a7a533cd
JR
23struct lttng_tracker_ids {
24 struct lttng_tracker_id *id_array;
25 unsigned int count;
26};
27
2d97a006
JR
28LTTNG_HIDDEN
29bool lttng_tracker_id_is_equal(const struct lttng_tracker_id *left,
30 const struct lttng_tracker_id *right);
31
a7a533cd
JR
32/*
33 * A copy acts like memcpy. It does not allocate new memory.
34 */
35LTTNG_HIDDEN
36int lttng_tracker_id_copy(struct lttng_tracker_id *dest,
37 const struct lttng_tracker_id *src);
38
39/*
40 * Duplicate an lttng_tracker_id.
41 * The returned object must be freed via lttng_tracker_id_destroy.
42 */
43LTTNG_HIDDEN
44struct lttng_tracker_id *lttng_tracker_id_duplicate(
45 const struct lttng_tracker_id *src);
46
47/*
48 * Allocate a new list of lttng_tracker_id.
49 * The returned object must be freed via lttng_tracker_ids_destroy.
50 */
51LTTNG_HIDDEN
52struct lttng_tracker_ids *lttng_tracker_ids_create(unsigned int base_count);
53
54/*
55 * Return the non-const pointer of an element at index "index" of a
56 * lttng_tracker_ids.
57 *
58 * The ownership of the lttng_tracker_id element is NOT transfered.
59 * The returned object can NOT be freed via lttng_tracker_id_destroy.
60 */
2d97a006 61LTTNG_HIDDEN
a7a533cd
JR
62struct lttng_tracker_id *lttng_tracker_ids_get_pointer_of_index(
63 const struct lttng_tracker_ids *list, unsigned int index);
2d97a006 64
f19f5c96
JR
65/*
66 * Serialize a ids collection to a lttng_dynamic_buffer.
67 * Return LTTNG_OK on success, negative lttng error code on error.
68 */
69LTTNG_HIDDEN
70int lttng_tracker_ids_serialize(const struct lttng_tracker_ids *ids,
71 struct lttng_dynamic_buffer *buffer);
72
2d97a006 73#endif /* LTTNG_TRACKER_INTERNAL_H */
This page took 0.027385 seconds and 5 git commands to generate.