+/*
+ * Add agent object to the given hash table.
+ */
+void agent_add(struct agent *agt, struct lttng_ht *ht)
+{
+ assert(agt);
+ assert(ht);
+
+ DBG3("Agent adding from domain %d", agt->domain);
+
+ rcu_read_lock();
+ lttng_ht_add_unique_u64(ht, &agt->node);
+ rcu_read_unlock();
+}
+
+/*
+ * Create an agent object for the given domain.
+ *
+ * Return the allocated agent or NULL on error.
+ */
+struct agent *agent_create(enum lttng_domain_type domain)
+{
+ int ret;
+ struct agent *agt;
+
+ agt = zmalloc(sizeof(*agt));
+ if (!agt) {
+ goto error;
+ }
+ agt->domain = domain;
+
+ ret = agent_init(agt);
+ if (ret < 0) {
+ free(agt);
+ agt = NULL;
+ goto error;
+ }
+
+error:
+ return agt;
+}
+