struct lttng_action *lttng_action_snapshot_session_create(void)
{
- struct lttng_action *action = NULL;
+ struct lttng_action_snapshot_session *action_snapshot = NULL;
struct lttng_rate_policy *policy = NULL;
enum lttng_action_status status;
goto end;
}
- action = (lttng_action *) zmalloc(sizeof(struct lttng_action_snapshot_session));
- if (!action) {
+ action_snapshot = zmalloc<lttng_action_snapshot_session>();
+ if (!action_snapshot) {
goto end;
}
- lttng_action_init(action, LTTNG_ACTION_TYPE_SNAPSHOT_SESSION,
+ lttng_action_init(&action_snapshot->parent,
+ LTTNG_ACTION_TYPE_SNAPSHOT_SESSION,
lttng_action_snapshot_session_validate,
lttng_action_snapshot_session_serialize,
lttng_action_snapshot_session_is_equal,
lttng_action_generic_add_error_query_results,
lttng_action_snapshot_session_mi_serialize);
- status = lttng_action_snapshot_session_set_rate_policy(action, policy);
+ status = lttng_action_snapshot_session_set_rate_policy(
+ &action_snapshot->parent, policy);
if (status != LTTNG_ACTION_STATUS_OK) {
- free(action);
- action = NULL;
+ lttng_action_destroy(&action_snapshot->parent);
+ action_snapshot = NULL;
goto end;
}
end:
lttng_rate_policy_destroy(policy);
- return action;
+ return action_snapshot ? &action_snapshot->parent : nullptr;
}
enum lttng_action_status lttng_action_snapshot_session_set_session_name(