LTTNG_HIDDEN
int lttng_action_path_copy(const struct lttng_action_path *src,
- struct lttng_action_path *dst)
+ struct lttng_action_path **dst)
{
int ret;
- size_t i, src_count;
+ struct lttng_action_path *new_path;
assert(src);
assert(dst);
- lttng_dynamic_array_init(&dst->indexes, sizeof(uint64_t), NULL);
- src_count = lttng_dynamic_array_get_count(&src->indexes);
-
- for (i = 0; i < src_count; i++) {
- const void *index = lttng_dynamic_array_get_element(
- &src->indexes, i);
-
- ret = lttng_dynamic_array_add_element(&dst->indexes, index);
- if (ret) {
- goto error;
- }
+ new_path = lttng_action_path_create(
+ (uint64_t *) lttng_dynamic_array_get_element(
+ &src->indexes, 0),
+ lttng_dynamic_array_get_count(&src->indexes));
+ if (!new_path) {
+ ret = -1;
+ } else {
+ ret = 0;
+ *dst = new_path;
}
- ret = 0;
- goto end;
-error:
- lttng_dynamic_array_reset(&dst->indexes);
-end:
return ret;
}
struct lttng_error_query parent;
/* Mutable only because of the reference count. */
struct lttng_trigger *trigger;
- struct lttng_action_path action_path;
+ struct lttng_action_path *action_path;
};
struct lttng_error_query_result {
void lttng_error_query_destroy(struct lttng_error_query *query)
{
- struct lttng_error_query_trigger *trigger_query;
-
if (!query) {
return;
}
- trigger_query = container_of(query, typeof(*trigger_query), parent);
- lttng_trigger_put(trigger_query->trigger);
- free(trigger_query);
+ switch (query->target_type) {
+ case LTTNG_ERROR_QUERY_TARGET_TYPE_TRIGGER:
+ {
+ struct lttng_error_query_trigger *trigger_query =
+ container_of(query, typeof(*trigger_query),
+ parent);
+
+ lttng_trigger_put(trigger_query->trigger);
+ free(trigger_query);
+ break;
+ }
+ case LTTNG_ERROR_QUERY_TARGET_TYPE_CONDITION:
+ {
+ struct lttng_error_query_condition *condition_query =
+ container_of(query, typeof(*condition_query),
+ parent);
+
+ lttng_trigger_put(condition_query->trigger);
+ free(condition_query);
+ break;
+ }
+ case LTTNG_ERROR_QUERY_TARGET_TYPE_ACTION:
+ {
+ struct lttng_error_query_action *action_query =
+ container_of(query, typeof(*action_query),
+ parent);
+
+ lttng_trigger_put(action_query->trigger);
+ lttng_action_path_destroy(action_query->action_path);
+ free(action_query);
+ break;
+ }
+ default:
+ abort();
+ }
}
static
goto end;
}
- ret = lttng_action_path_serialize(&query_action->action_path, payload);
+ ret = lttng_action_path_serialize(query_action->action_path, payload);
if (ret) {
goto end;
}
container_of(query, typeof(*query_action), parent);
return get_trigger_action_from_path(
- trigger, &query_action->action_path);
+ trigger, query_action->action_path);
}
LTTNG_HIDDEN