- if (dom) {
- switch (dom->type) {
- case LTTNG_DOMAIN_KERNEL:
- case LTTNG_DOMAIN_UST:
- case LTTNG_DOMAIN_UST_EXEC_NAME:
- case LTTNG_DOMAIN_UST_PID:
- case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN:
- memcpy(&lsm.domain, dom, sizeof(struct lttng_domain));
- break;
- default:
- lsm.domain.type = LTTNG_DOMAIN_KERNEL;
- break;
- }
+ struct lttng_handle *handle;
+
+ handle = malloc(sizeof(struct lttng_handle));
+ if (handle == NULL) {
+ perror("malloc handle");
+ goto end;
+ }
+
+ /* Copy session name */
+ copy_string(handle->session_name, session_name,
+ sizeof(handle->session_name));
+
+ /* Copy lttng domain */
+ copy_lttng_domain(&handle->domain, domain);
+
+end:
+ return handle;
+}
+
+/*
+ * Destroy handle by free(3) the pointer.
+ */
+void lttng_destroy_handle(struct lttng_handle *handle)
+{
+ if (handle) {
+ free(handle);