Add type-checked versions of allocation and deallocations functions
[lttng-tools.git] / src / common / error-query.cpp
index 5d369c9e07563bfdba794694b69b22e1c74bb9a0..13efbbfd7d03f6154ceca9dcc8f9b7b2e8fb69fb 100644 (file)
@@ -7,17 +7,17 @@
  *
  */
 
-#include <common/dynamic-array.h>
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <lttng/action/action-internal.h>
-#include <lttng/action/list-internal.h>
-#include <lttng/action/path-internal.h>
-#include <lttng/error-query-internal.h>
+#include <common/dynamic-array.hpp>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <lttng/action/action-internal.hpp>
+#include <lttng/action/list-internal.hpp>
+#include <lttng/action/path-internal.hpp>
+#include <lttng/error-query-internal.hpp>
 #include <lttng/error-query.h>
-#include <lttng/trigger/trigger-internal.h>
+#include <lttng/trigger/trigger-internal.hpp>
 #include <stddef.h>
 
 struct lttng_error_query {
@@ -111,7 +111,7 @@ struct lttng_error_query *lttng_error_query_trigger_create(
                goto end;
        }
 
-       query = (lttng_error_query_trigger *) zmalloc(sizeof(*query));
+       query = zmalloc<lttng_error_query_trigger>();
        if (!query) {
                PERROR("Failed to allocate trigger error query");
                goto error;
@@ -142,7 +142,7 @@ struct lttng_error_query *lttng_error_query_condition_create(
                goto end;
        }
 
-       query = (lttng_error_query_condition *) zmalloc(sizeof(*query));
+       query = zmalloc<lttng_error_query_condition>();
        if (!query) {
                PERROR("Failed to allocate condition error query");
                goto error;
@@ -221,7 +221,7 @@ struct lttng_error_query *lttng_error_query_action_create(
                goto end;
        }
 
-       query = (lttng_error_query_action *) zmalloc(sizeof(*query));
+       query = zmalloc<lttng_error_query_action>();
        if (!query) {
                PERROR("Failed to allocate action error query");
                goto error;
@@ -388,7 +388,7 @@ lttng_error_query_result_counter_create(
        int init_ret;
        struct lttng_error_query_result_counter *counter;
 
-       counter = (lttng_error_query_result_counter *) zmalloc(sizeof(*counter));
+       counter = zmalloc<lttng_error_query_result_counter>();
        if (!counter) {
                PERROR("Failed to allocate error query counter result");
                goto end;
@@ -419,7 +419,7 @@ void destroy_result(void *ptr)
 
 struct lttng_error_query_results *lttng_error_query_results_create(void)
 {
-       struct lttng_error_query_results *set = (lttng_error_query_results *) zmalloc(sizeof(*set));
+       struct lttng_error_query_results *set = zmalloc<lttng_error_query_results>();
 
        if (!set) {
                PERROR("Failed to allocate an error query result set");
@@ -536,7 +536,7 @@ int lttng_error_query_results_serialize(
        const size_t result_count = lttng_dynamic_pointer_array_get_count(
                        &results->results);
        const struct lttng_error_query_results_comm header = {
-               .count = (typeof(header.count)) result_count,
+               .count = (decltype(header.count)) result_count,
        };
 
        /* Header. */
@@ -744,7 +744,7 @@ int lttng_error_query_serialize(const struct lttng_error_query *query,
 {
        int ret;
        const struct lttng_error_query_comm header = {
-               .target_type = (typeof(header.target_type)) query->target_type,
+               .target_type = (decltype(header.target_type)) query->target_type,
        };
 
        ret = lttng_dynamic_buffer_append(
This page took 0.028389 seconds and 4 git commands to generate.