+enum bt_value_status bt_value_map_extend(
+ struct bt_private_value **extended_map_obj,
+ const struct bt_value *base_map_obj,
+ const struct bt_value *extension_obj)
+{
+ struct extend_map_element_data extend_data = {
+ .extended_obj = NULL,
+ .status = BT_VALUE_STATUS_OK,
+ };
+
+ BT_ASSERT_PRE_NON_NULL(base_map_obj, "Base value object");
+ BT_ASSERT_PRE_NON_NULL(extension_obj, "Extension value object");
+ BT_ASSERT_PRE_NON_NULL(extended_map_obj,
+ "Extended value object (output)");
+ BT_ASSERT_PRE_VALUE_IS_TYPE(base_map_obj, BT_VALUE_TYPE_MAP);
+ BT_ASSERT_PRE_VALUE_IS_TYPE(extension_obj, BT_VALUE_TYPE_MAP);
+ BT_LOGD("Extending map value: base-value-addr=%p, extension-value-addr=%p",
+ base_map_obj, extension_obj);
+ *extended_map_obj = NULL;
+
+ /* Create copy of base map object to start with */
+ extend_data.status = bt_value_copy(extended_map_obj, base_map_obj);
+ if (extend_data.status) {
+ BT_LOGE("Cannot copy base value: base-value-addr=%p",
+ base_map_obj);
+ goto error;
+ }
+
+ BT_ASSERT(extended_map_obj);
+
+ /*
+ * For each key in the extension map object, replace this key
+ * in the copied map object.
+ */
+ extend_data.extended_obj = *extended_map_obj;
+
+ if (bt_value_map_foreach_entry(extension_obj, extend_map_element,
+ &extend_data)) {
+ BT_LOGE("Cannot iterate on the extension object's elements: "
+ "extension-value-addr=%p", extension_obj);
+ goto error;
+ }
+
+ if (extend_data.status) {
+ BT_LOGE("Failed to successfully iterate on the extension object's elements: "
+ "extension-value-addr=%p", extension_obj);
+ goto error;
+ }
+
+ BT_LOGD("Extended map value: extended-value-addr=%p",
+ *extended_map_obj);
+ goto end;
+
+error:
+ BT_OBJECT_PUT_REF_AND_RESET(*extended_map_obj);
+ *extended_map_obj = NULL;
+
+end:
+ return extend_data.status;
+}
+
+enum bt_value_status bt_value_copy(struct bt_private_value **copy_obj,
+ const struct bt_value *object)