.gitignore: ignore local vscode workspace settings file
[lttng-tools.git] / src / common / actions / rate-policy.cpp
index a25ee3e1572bfd79e6c5312f1cce8df32cea1d59..60def0d9d45231b45878890543f17447a120e271 100644 (file)
 #define IS_ONCE_AFTER_N_RATE_POLICY(policy) \
        (lttng_rate_policy_get_type(policy) == LTTNG_RATE_POLICY_TYPE_ONCE_AFTER_N)
 
-typedef void (*rate_policy_destroy_cb)(struct lttng_rate_policy *rate_policy);
-typedef int (*rate_policy_serialize_cb)(struct lttng_rate_policy *rate_policy,
-                                       struct lttng_payload *payload);
-typedef bool (*rate_policy_equal_cb)(const struct lttng_rate_policy *a,
-                                    const struct lttng_rate_policy *b);
-typedef ssize_t (*rate_policy_create_from_payload_cb)(struct lttng_payload_view *view,
-                                                     struct lttng_rate_policy **rate_policy);
-typedef struct lttng_rate_policy *(*rate_policy_copy_cb)(const struct lttng_rate_policy *source);
-typedef enum lttng_error_code (*rate_policy_mi_serialize_cb)(
-       const struct lttng_rate_policy *rate_policy, struct mi_writer *writer);
+using rate_policy_destroy_cb = void (*)(struct lttng_rate_policy *);
+using rate_policy_serialize_cb = int (*)(struct lttng_rate_policy *, struct lttng_payload *);
+using rate_policy_equal_cb = bool (*)(const struct lttng_rate_policy *,
+                                     const struct lttng_rate_policy *);
+using rate_policy_create_from_payload_cb = ssize_t (*)(struct lttng_payload_view *,
+                                                      struct lttng_rate_policy **);
+using rate_policy_copy_cb = struct lttng_rate_policy *(*) (const struct lttng_rate_policy *);
+using rate_policy_mi_serialize_cb = enum lttng_error_code (*)(const struct lttng_rate_policy *,
+                                                             struct mi_writer *);
 
 struct lttng_rate_policy {
        enum lttng_rate_policy_type type;
@@ -157,7 +156,7 @@ lttng_rate_policy_once_after_n_create_from_payload(struct lttng_payload_view *vi
                                                   struct lttng_rate_policy **rate_policy)
 {
        ssize_t consumed_len = -1;
-       struct lttng_rate_policy *policy = NULL;
+       struct lttng_rate_policy *policy = nullptr;
        const struct lttng_rate_policy_once_after_n_comm *comm;
        const struct lttng_payload_view comm_view =
                lttng_payload_view_from_view(view, 0, sizeof(*comm));
@@ -176,7 +175,7 @@ lttng_rate_policy_once_after_n_create_from_payload(struct lttng_payload_view *vi
        comm = (const struct lttng_rate_policy_once_after_n_comm *) comm_view.buffer.data;
 
        policy = lttng_rate_policy_once_after_n_create(comm->threshold);
-       if (policy == NULL) {
+       if (policy == nullptr) {
                consumed_len = -1;
                goto end;
        }
@@ -192,7 +191,7 @@ static ssize_t lttng_rate_policy_every_n_create_from_payload(struct lttng_payloa
                                                             struct lttng_rate_policy **rate_policy)
 {
        ssize_t consumed_len = -1;
-       struct lttng_rate_policy *policy = NULL;
+       struct lttng_rate_policy *policy = nullptr;
        const struct lttng_rate_policy_every_n_comm *comm;
        const struct lttng_payload_view comm_view =
                lttng_payload_view_from_view(view, 0, sizeof(*comm));
@@ -211,7 +210,7 @@ static ssize_t lttng_rate_policy_every_n_create_from_payload(struct lttng_payloa
        comm = (const struct lttng_rate_policy_every_n_comm *) comm_view.buffer.data;
 
        policy = lttng_rate_policy_every_n_create(comm->interval);
-       if (policy == NULL) {
+       if (policy == nullptr) {
                consumed_len = -1;
                goto end;
        }
@@ -399,7 +398,7 @@ end:
 static struct lttng_rate_policy *
 lttng_rate_policy_every_n_copy(const struct lttng_rate_policy *source)
 {
-       struct lttng_rate_policy *copy = NULL;
+       struct lttng_rate_policy *copy = nullptr;
        const struct lttng_rate_policy_every_n *every_n_policy;
 
        if (!source) {
@@ -419,7 +418,7 @@ lttng_rate_policy_every_n_mi_serialize(const struct lttng_rate_policy *rate_poli
 {
        int ret;
        enum lttng_error_code ret_code;
-       const struct lttng_rate_policy_every_n *every_n_policy = NULL;
+       const struct lttng_rate_policy_every_n *every_n_policy = nullptr;
 
        LTTNG_ASSERT(rate_policy);
        LTTNG_ASSERT(IS_EVERY_N_RATE_POLICY(rate_policy));
@@ -457,8 +456,8 @@ end:
 
 struct lttng_rate_policy *lttng_rate_policy_every_n_create(uint64_t interval)
 {
-       struct lttng_rate_policy_every_n *policy = NULL;
-       struct lttng_rate_policy *_policy = NULL;
+       struct lttng_rate_policy_every_n *policy = nullptr;
+       struct lttng_rate_policy *_policy = nullptr;
 
        if (interval == 0) {
                /*
@@ -483,7 +482,7 @@ struct lttng_rate_policy *lttng_rate_policy_every_n_create(uint64_t interval)
        policy->interval = interval;
 
        _policy = &policy->parent;
-       policy = NULL;
+       policy = nullptr;
 
 end:
        free(policy);
@@ -605,7 +604,7 @@ end:
 static struct lttng_rate_policy *
 lttng_rate_policy_once_after_n_copy(const struct lttng_rate_policy *source)
 {
-       struct lttng_rate_policy *copy = NULL;
+       struct lttng_rate_policy *copy = nullptr;
        const struct lttng_rate_policy_once_after_n *once_after_n_policy;
 
        if (!source) {
@@ -625,7 +624,7 @@ lttng_rate_policy_once_after_n_mi_serialize(const struct lttng_rate_policy *rate
 {
        int ret;
        enum lttng_error_code ret_code;
-       const struct lttng_rate_policy_once_after_n *once_after_n_policy = NULL;
+       const struct lttng_rate_policy_once_after_n *once_after_n_policy = nullptr;
 
        LTTNG_ASSERT(rate_policy);
        LTTNG_ASSERT(IS_ONCE_AFTER_N_RATE_POLICY(rate_policy));
@@ -665,8 +664,8 @@ end:
 
 struct lttng_rate_policy *lttng_rate_policy_once_after_n_create(uint64_t threshold)
 {
-       struct lttng_rate_policy_once_after_n *policy = NULL;
-       struct lttng_rate_policy *_policy = NULL;
+       struct lttng_rate_policy_once_after_n *policy = nullptr;
+       struct lttng_rate_policy *_policy = nullptr;
 
        if (threshold == 0) {
                /* threshold is expected to be > 0 */
@@ -689,7 +688,7 @@ struct lttng_rate_policy *lttng_rate_policy_once_after_n_create(uint64_t thresho
        policy->threshold = threshold;
 
        _policy = &policy->parent;
-       policy = NULL;
+       policy = nullptr;
 
 end:
        free(policy);
This page took 0.02656 seconds and 4 git commands to generate.