Re-format with clang-format 16
[babeltrace.git] / src / bindings / python / bt2 / bt2 / native_bt_value.i.h
1 /*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright (c) 2016 Philippe Proulx <pproulx@efficios.com>
5 */
6
7 #ifndef BABELTRACE_BINDINGS_PYTHON_BT2_BT2_NATIVE_BT_VALUE_I_H
8 #define BABELTRACE_BINDINGS_PYTHON_BT2_BT2_NATIVE_BT_VALUE_I_H
9
10 struct bt_value_map_get_keys_data {
11 struct bt_value *keys;
12 };
13
14 static bt_value_map_foreach_entry_const_func_status bt_value_map_get_keys_cb(
15 const char *key, const struct bt_value *object, void *data)
16 {
17 int status;
18 struct bt_value_map_get_keys_data *priv_data = data;
19
20 status = bt_value_array_append_string_element(priv_data->keys, key);
21 BT_ASSERT(status == __BT_FUNC_STATUS_OK ||
22 status == __BT_FUNC_STATUS_MEMORY_ERROR);
23 return status;
24 }
25
26 static struct bt_value *bt_value_map_get_keys(const struct bt_value *map_obj)
27 {
28 bt_value_map_foreach_entry_const_status status;
29 struct bt_value_map_get_keys_data data;
30
31 data.keys = bt_value_array_create();
32 if (!data.keys) {
33 return NULL;
34 }
35
36 status = bt_value_map_foreach_entry_const(map_obj, bt_value_map_get_keys_cb,
37 &data);
38 if (status != __BT_FUNC_STATUS_OK) {
39 goto error;
40 }
41
42 goto end;
43
44 error:
45 if (data.keys) {
46 BT_VALUE_PUT_REF_AND_RESET(data.keys);
47 }
48
49 end:
50 return data.keys;
51 }
52
53 #endif /* BABELTRACE_BINDINGS_PYTHON_BT2_BT2_NATIVE_BT_VALUE_I_H */
This page took 0.030728 seconds and 5 git commands to generate.