X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=ltt-sessiond%2Fchannel.c;h=350bab6ab5a87b96fc12934d3b88cc4df73eba96;hp=818f6dcfd476d7d586a480da6ebd2219d7709729;hb=56fff0907d3a752030f384e6037d16ea7978de71;hpb=4bc385dd824ca7c10e3177346926350c86d04754 diff --git a/ltt-sessiond/channel.c b/ltt-sessiond/channel.c index 818f6dcfd..350bab6ab 100644 --- a/ltt-sessiond/channel.c +++ b/ltt-sessiond/channel.c @@ -15,6 +15,7 @@ * Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include #include #include @@ -72,6 +73,35 @@ error_alloc: return NULL; } +/* + * Copy two ltt ust channel. Dst and src must be already allocated. + */ +int channel_ust_copy(struct ltt_ust_channel *dst, + struct ltt_ust_channel *src) +{ + struct ltt_ust_event *uevent, *new_uevent; + + memcpy(dst, src, sizeof(struct ltt_ust_channel)); + CDS_INIT_LIST_HEAD(&dst->events.head); + + cds_list_for_each_entry(uevent, &src->events.head, list) { + new_uevent = malloc(sizeof(struct ltt_ust_event)); + if (new_uevent == NULL) { + perror("malloc ltt_ust_event"); + goto error; + } + + memcpy(new_uevent, uevent, sizeof(struct ltt_ust_event)); + cds_list_add(&new_uevent->list, &dst->events.head); + dst->events.count++; + } + + return 0; + +error: + return -1; +} + /* * Disable kernel channel of the kernel session. */