struct bt_ctf_event_class *bt_ctf_event_class_create(const char *name) { int ret; struct bt_value *obj = NULL; struct bt_ctf_event_class *event_class = NULL; if (bt_ctf_validate_identifier(name)) { goto error; } event_class = g_new0(struct bt_ctf_event_class, 1); if (!event_class) { goto error; } bt_object_init(event_class, bt_ctf_event_class_destroy); event_class->fields = bt_ctf_field_type_structure_create(); if (!event_class->fields) { goto error; } event_class->attributes = bt_ctf_attributes_create(); if (!event_class->attributes) { goto error; } obj = bt_value_integer_create_init(-1); if (!obj) { goto error; } ret = bt_ctf_attributes_set_field_value(event_class->attributes, "id", obj); if (ret) { goto error; } BT_PUT(obj); obj = bt_value_string_create_init(name); if (!obj) { goto error; } ret = bt_ctf_attributes_set_field_value(event_class->attributes, "name", obj); if (ret) { goto error; } BT_PUT(obj); return event_class; error: BT_PUT(event_class); BT_PUT(obj); return event_class; }
enum bt_value_status bt_value_array_append_string_element( struct bt_value *array_obj, const char *val) { enum bt_value_status ret; struct bt_value *string_obj = NULL; string_obj = bt_value_string_create_init(val); ret = bt_value_array_append_element(array_obj, (void *) string_obj); bt_object_put_ref(string_obj); return ret; }
enum bt_value_status bt_value_map_insert_string_entry( struct bt_value *map_obj, const char *key, const char *val) { enum bt_value_status ret; struct bt_value *string_obj = NULL; string_obj = bt_value_string_create_init(val); ret = bt_value_map_insert_entry(map_obj, key, (void *) string_obj); bt_object_put_ref(string_obj); return ret; }
int bt_ctf_trace_set_environment_field_string(struct bt_ctf_trace *trace, const char *name, const char *value) { int ret = 0; struct bt_value *env_value_string_obj = NULL; if (!trace || !name || !value) { ret = -1; goto end; } if (trace->frozen) { /* * New environment fields may be added to a frozen trace, * but existing fields may not be changed. */ struct bt_value *attribute = bt_ctf_attributes_get_field_value_by_name( trace->environment, name); if (attribute) { BT_PUT(attribute); ret = -1; goto end; } } env_value_string_obj = bt_value_string_create_init(value); if (!env_value_string_obj) { ret = -1; goto end; } if (trace->frozen) { bt_value_freeze(env_value_string_obj); } ret = bt_ctf_trace_set_environment_field(trace, name, env_value_string_obj); end: BT_PUT(env_value_string_obj); return ret; }
struct bt_value *bt_value_string_create(void) { return bt_value_string_create_init(""); }
static struct bt_value *bt_value_string_copy(const struct bt_value *string_obj) { return bt_value_string_create_init( BT_VALUE_TO_STRING(string_obj)->gstr->str); }