Add type-checked versions of allocation and deallocations functions
[lttng-tools.git] / src / common / actions / snapshot-session.cpp
index 600d803e3610b1d065a23cbe82e7fc79e2151596..c3570081abcdf2248137fdd8c631403a3c45c0bf 100644 (file)
@@ -445,7 +445,7 @@ end:
 
 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;
 
@@ -455,12 +455,13 @@ struct lttng_action *lttng_action_snapshot_session_create(void)
                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,
@@ -469,16 +470,17 @@ struct lttng_action *lttng_action_snapshot_session_create(void)
                        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(
This page took 0.023311 seconds and 4 git commands to generate.