From 0df078e5f68193e1eeae377cad44a8e36d563ee2 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Thu, 6 Apr 2017 02:10:42 -0400 Subject: [PATCH] bt_component_create(): create convenient empty map parameters when NULL MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- lib/graph/component.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/graph/component.c b/lib/graph/component.c index 26d77605..31abc073 100644 --- a/lib/graph/component.c +++ b/lib/graph/component.c @@ -195,6 +195,8 @@ struct bt_component *bt_component_create_with_init_method_data( enum bt_component_class_type type; struct bt_port *default_port = NULL; + bt_get(params); + if (!component_class) { goto end; } @@ -205,6 +207,21 @@ struct bt_component *bt_component_create_with_init_method_data( goto end; } + /* + * Parameters must be a map value, but we create a convenient + * empty one if it's NULL. + */ + if (params) { + if (!bt_value_is_map(params)) { + goto end; + } + } else { + params = bt_value_map_create(); + if (!params) { + goto end; + } + } + component = component_create_funcs[type](component_class, params); if (!component) { goto end; @@ -281,6 +298,7 @@ struct bt_component *bt_component_create_with_init_method_data( bt_component_class_freeze(component->class); end: + bt_put(params); bt_put(default_port); return component; } -- 2.34.1