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)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 16 Aug 2019 16:33:32 +0000 (12:33 -0400)
commit847ab606a7c62eccf63c86e4030a667e57d5b3e8
tree102d854783da7126a26553e881f7f6537a14236d
parentf03cdb2bdd377013c66f7ed9b2533d7d90f33fb8
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.024592 seconds and 4 git commands to generate.