Move to kernel style SPDX license identifiers
[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 struct bt_value_map_get_keys_data {
8 struct bt_value *keys;
9 };
10
11 static bt_value_map_foreach_entry_const_func_status bt_value_map_get_keys_cb(
12 const char *key, const struct bt_value *object, void *data)
13 {
14 int status;
15 struct bt_value_map_get_keys_data *priv_data = data;
16
17 status = bt_value_array_append_string_element(priv_data->keys, key);
18 BT_ASSERT(status == __BT_FUNC_STATUS_OK ||
19 status == __BT_FUNC_STATUS_MEMORY_ERROR);
20 return status;
21 }
22
23 static struct bt_value *bt_value_map_get_keys(const struct bt_value *map_obj)
24 {
25 bt_value_map_foreach_entry_const_status status;
26 struct bt_value_map_get_keys_data data;
27
28 data.keys = bt_value_array_create();
29 if (!data.keys) {
30 return NULL;
31 }
32
33 status = bt_value_map_foreach_entry_const(map_obj, bt_value_map_get_keys_cb,
34 &data);
35 if (status != __BT_FUNC_STATUS_OK) {
36 goto error;
37 }
38
39 goto end;
40
41 error:
42 if (data.keys) {
43 BT_VALUE_PUT_REF_AND_RESET(data.keys);
44 }
45
46 end:
47 return data.keys;
48 }
This page took 0.029734 seconds and 4 git commands to generate.