bt_component_create(): create convenient empty map parameters when NULL
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 6 Apr 2017 06:10:42 +0000 (02:10 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 28 May 2017 16:57:40 +0000 (12:57 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
lib/graph/component.c

index 26d77605be391eb197814d43f67b8af38ca8d3fa..31abc0737c554574e18e5b09df5bd79ff0474132 100644 (file)
@@ -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;
 }
This page took 0.025079 seconds and 4 git commands to generate.