X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Flib%2Fvalue.c;h=c8865ebc05c2d37eb451a3ccbb6bf1acdd920073;hb=6871026b82224d83bb63cbb44cc33c16c766d96d;hp=183d2081f32de63eca90b14e2b5032b635353712;hpb=9c08c816a55bbc538957648b49d41354e43c7cdf;p=babeltrace.git diff --git a/src/lib/value.c b/src/lib/value.c index 183d2081..c8865ebc 100644 --- a/src/lib/value.c +++ b/src/lib/value.c @@ -136,6 +136,9 @@ void (* const destroy_funcs[])(struct bt_value *) = { static struct bt_value *bt_value_null_copy(const struct bt_value *null_obj) { + BT_ASSERT(null_obj == bt_value_null); + + bt_object_get_ref_no_null_check(bt_value_null); return (void *) bt_value_null; } @@ -386,14 +389,14 @@ bt_bool bt_value_array_compare(const struct bt_value *object_a, const struct bt_value_array *array_obj_a = BT_VALUE_TO_ARRAY(object_a); - if (bt_value_array_get_size(object_a) != - bt_value_array_get_size(object_b)) { + if (bt_value_array_get_length(object_a) != + bt_value_array_get_length(object_b)) { BT_LOGT("Array values are different: size mismatch " "value-a-addr=%p, value-b-addr=%p, " "value-a-size=%" PRId64 ", value-b-size=%" PRId64, object_a, object_b, - bt_value_array_get_size(object_a), - bt_value_array_get_size(object_b)); + bt_value_array_get_length(object_a), + bt_value_array_get_length(object_b)); ret = BT_FALSE; goto end; } @@ -879,7 +882,7 @@ enum bt_value_string_set_status bt_value_string_set( return BT_FUNC_STATUS_OK; } -uint64_t bt_value_array_get_size(const struct bt_value *array_obj) +uint64_t bt_value_array_get_length(const struct bt_value *array_obj) { BT_ASSERT_PRE_DEV_NON_NULL(array_obj, "Value object"); BT_ASSERT_PRE_DEV_VALUE_IS_TYPE(array_obj, BT_VALUE_TYPE_ARRAY); @@ -994,7 +997,8 @@ bt_value_array_append_string_element(struct bt_value *array_obj, } enum bt_value_array_append_element_status -bt_value_array_append_empty_array_element(struct bt_value *array_obj) +bt_value_array_append_empty_array_element(struct bt_value *array_obj, + struct bt_value **element_obj) { enum bt_value_array_append_element_status ret; struct bt_value *empty_array_obj = NULL; @@ -1002,12 +1006,18 @@ bt_value_array_append_empty_array_element(struct bt_value *array_obj) empty_array_obj = bt_value_array_create(); ret = bt_value_array_append_element(array_obj, (void *) empty_array_obj); + + if (element_obj) { + *element_obj = empty_array_obj; + } + bt_object_put_ref(empty_array_obj); return ret; } enum bt_value_array_append_element_status -bt_value_array_append_empty_map_element(struct bt_value *array_obj) +bt_value_array_append_empty_map_element(struct bt_value *array_obj, + struct bt_value **element_obj) { enum bt_value_array_append_element_status ret; struct bt_value *map_obj = NULL; @@ -1015,6 +1025,11 @@ bt_value_array_append_empty_map_element(struct bt_value *array_obj) map_obj = bt_value_map_create(); ret = bt_value_array_append_element(array_obj, (void *) map_obj); + + if (element_obj) { + *element_obj = map_obj; + } + bt_object_put_ref(map_obj); return ret; } @@ -1160,7 +1175,8 @@ enum bt_value_map_insert_entry_status bt_value_map_insert_string_entry( enum bt_value_map_insert_entry_status bt_value_map_insert_empty_array_entry( - struct bt_value *map_obj, const char *key) + struct bt_value *map_obj, const char *key, + bt_value **entry_obj) { enum bt_value_map_insert_entry_status ret; struct bt_value *array_obj = NULL; @@ -1168,12 +1184,18 @@ bt_value_map_insert_empty_array_entry( array_obj = bt_value_array_create(); ret = bt_value_map_insert_entry(map_obj, key, (void *) array_obj); + + if (entry_obj) { + *entry_obj = array_obj; + } + bt_object_put_ref(array_obj); return ret; } enum bt_value_map_insert_entry_status -bt_value_map_insert_empty_map_entry(struct bt_value *map_obj, const char *key) +bt_value_map_insert_empty_map_entry(struct bt_value *map_obj, const char *key, + bt_value **entry_obj) { enum bt_value_map_insert_entry_status ret; struct bt_value *empty_map_obj = NULL; @@ -1181,6 +1203,11 @@ bt_value_map_insert_empty_map_entry(struct bt_value *map_obj, const char *key) empty_map_obj = bt_value_map_create(); ret = bt_value_map_insert_entry(map_obj, key, (void *) empty_map_obj); + + if (entry_obj) { + *entry_obj = empty_map_obj; + } + bt_object_put_ref(empty_map_obj); return ret; } @@ -1203,10 +1230,10 @@ enum bt_value_map_foreach_entry_status bt_value_map_foreach_entry( const char *key_str = g_quark_to_string(GPOINTER_TO_UINT(key)); if (!func(key_str, element_obj, data)) { - BT_LOGT("User canceled the loop: key=\"%s\", " + BT_LOGT("User interrupted the loop: key=\"%s\", " "value-addr=%p, data=%p", key_str, element_obj, data); - ret = BT_FUNC_STATUS_CANCELED; + ret = BT_FUNC_STATUS_INTERRUPTED; break; } }