+
+ strncpy(llm->trace_name, lsm->trace_name, strlen(llm->trace_name));
+ llm->trace_name[strlen(llm->trace_name) - 1] = '\0';
+}
+
+/*
+ * setup_data_buffer
+ *
+ * Setup the outgoing data buffer for the response
+ * data allocating the right amount of memory.
+ *
+ * Return total size of the buffer pointed by buf.
+ */
+static int setup_data_buffer(char **buf, size_t s_data, struct lttcomm_lttng_msg *llm)
+{
+ int ret = 0;
+ size_t buf_size;
+
+ buf_size = sizeof(struct lttcomm_lttng_msg) + s_data;
+ *buf = malloc(buf_size);
+ if (*buf == NULL) {
+ perror("malloc");
+ ret = -1;
+ goto error;
+ }
+
+ /* Setup lttcomm_lttng_msg data and copy
+ * it to the newly allocated buffer.
+ */
+ llm->size_payload = s_data;
+ memcpy(*buf, llm, sizeof(struct lttcomm_lttng_msg));
+
+ return buf_size;
+
+error:
+ return ret;