/**
@brief Sets the name of the CTF IR stream class
- \p stream_class to \p name.
+ \p stream_class to \p name, or resets the name of
+ \p stream_class.
-\p name must be unique amongst the names of all the stream classes
-of the trace class to which you eventually add \p stream_class.
+If \p name is not \c NULL, it must be unique amongst the names of all
+the stream classes of the trace class to which you eventually add
+\p stream_class.
@param[in] stream_class Stream class of which to set the name.
-@param[in] name Name of the stream class (copied on success).
+@param[in] name Name of the stream class (copied on success), or
+ \c NULL to reset the name of \p stream_class
+ (make it unnamed).
@returns 0 on success, or a negative value on error.
@prenotnull{stream_class}
-@prenotnull{name}
@prehot{stream_class}
@postrefcountsame{stream_class}
void bt_ctf_stream_remove_destroy_listener(struct bt_ctf_stream *stream,
bt_ctf_stream_destroy_listener_func func, void *data);
+static inline
+struct bt_ctf_stream_class *bt_ctf_stream_borrow_stream_class(
+ struct bt_ctf_stream *stream)
+{
+ assert(stream);
+ return stream->stream_class;
+}
+
#endif /* BABELTRACE_CTF_WRITER_STREAM_INTERNAL_H */
goto end;
}
- name = stream_class->name->str;
+ name = stream_class->name->len > 0 ? stream_class->name->str : NULL;
end:
return name;
}
goto end;
}
- g_string_assign(stream_class->name, name);
+ if (!name) {
+ g_string_assign(stream_class->name, "");
+ } else {
+ if (strlen(name) == 0) {
+ BT_LOGW("Invalid parameter: name is empty.");
+ ret = -1;
+ goto end;
+ }
+
+ g_string_assign(stream_class->name, name);
+ }
+
BT_LOGV("Set stream class's name: "
"addr=%p, name=\"%s\", id=%" PRId64,
stream_class, bt_ctf_stream_class_get_name(stream_class),
int ret_int;
const char *name = bt_ctf_stream_class_get_name(stream_class);
- if (strlen(name) == 0) {
- name = NULL;
- }
-
writer_stream_class = bt_ctf_stream_class_create_empty(name);
if (!writer_stream_class) {
fprintf(err, "[error] %s in %s:%d\n",
int ret_int;
const char *name = bt_ctf_stream_class_get_name(stream_class);
- if (strlen(name) == 0) {
- name = NULL;
- }
-
writer_stream_class = bt_ctf_stream_class_create_empty(name);
if (!writer_stream_class) {
fprintf(err, "[error] %s in %s:%d\n",