lib: make empty array/map appending/inserting functions return new object
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 16 Aug 2019 01:01:49 +0000 (21:01 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 4 Sep 2019 15:58:22 +0000 (11:58 -0400)
commit1b8e14436f7ff7cc168aee612147c89e15424f4b
tree057e6cd7f3f30aa205feda512c787884326301fa
parent565281139c00d8af41a9b0ba501c1fab50ea6a53
lib: make empty array/map appending/inserting functions return new object

This makes the bt_value_array_append_empty_array_element(),
bt_value_array_append_empty_map_element(),
bt_value_map_insert_empty_array_entry(), and
bt_value_map_insert_empty_map_entry() accept a new optional output
parameter to return the created empty value object.

The goal of appending/inserting an empty array/map value object is
typically to fill it afterwards, so it makes this less painful, for
example:

    bt_value *inner_arr_obj;

    status = bt_value_array_append_empty_array_element(outer_array_obj,
        &inner_arr_obj);
    assert(status == 0);

    status = bt_value_array_append_bool_element(inner_arr_obj, true);
    assert(status == 0);

    status = bt_value_array_append_string_element(inner_arr_obj, "id");
    assert(status == 0);

You can pass `NULL` as this new parameter.

The returned reference is borrowed.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I2cd3359f357a3eb1da52c0e1426ef7804a4b13aa
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1948
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
include/babeltrace2/value.h
src/cli/babeltrace2-cfg-cli-args.c
src/lib/value.c
tests/lib/test_bt_values.c
This page took 0.026277 seconds and 4 git commands to generate.