Add type-checked versions of allocation and deallocations functions
[lttng-tools.git] / src / lib / lttng-ctl / lttng-ctl.cpp
index 68f8c1f7e01916c51c7299e6e660832aba029391..057a91e3e57f73f0b0afc5fd26e8c9f731efbb1e 100644 (file)
 #include <string.h>
 #include <unistd.h>
 
-#include <common/bytecode/bytecode.h>
-#include <common/align.h>
-#include <common/common.h>
-#include <common/compat/errno.h>
-#include <common/compat/string.h>
-#include <common/defaults.h>
-#include <common/dynamic-array.h>
-#include <common/dynamic-buffer.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/tracker.h>
-#include <common/unix.h>
-#include <common/uri.h>
-#include <common/utils.h>
-#include <lttng/channel-internal.h>
+#include <common/bytecode/bytecode.hpp>
+#include <common/align.hpp>
+#include <common/common.hpp>
+#include <common/compat/errno.hpp>
+#include <common/compat/string.hpp>
+#include <common/defaults.hpp>
+#include <common/dynamic-array.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/tracker.hpp>
+#include <common/unix.hpp>
+#include <common/uri.hpp>
+#include <common/utils.hpp>
+#include <lttng/channel-internal.hpp>
 #include <lttng/destruction-handle.h>
 #include <lttng/endpoint.h>
-#include <lttng/error-query-internal.h>
-#include <lttng/event-internal.h>
-#include <lttng/health-internal.h>
+#include <lttng/error-query-internal.hpp>
+#include <lttng/event-internal.hpp>
+#include <lttng/health-internal.hpp>
 #include <lttng/lttng-error.h>
 #include <lttng/lttng.h>
-#include <lttng/session-descriptor-internal.h>
-#include <lttng/session-internal.h>
-#include <lttng/trigger/trigger-internal.h>
-#include <lttng/userspace-probe-internal.h>
+#include <lttng/session-descriptor-internal.hpp>
+#include <lttng/session-internal.hpp>
+#include <lttng/trigger/trigger-internal.hpp>
+#include <lttng/userspace-probe-internal.hpp>
 
-#include "lttng-ctl-helper.h"
-#include <common/filter/filter-ast.h>
+#include "lttng-ctl-helper.hpp"
+#include <common/filter/filter-ast.hpp>
 #include <common/filter/filter-parser.hpp>
-#include <common/filter/memstream.h>
+#include <common/filter/memstream.hpp>
 
 #define COPY_DOMAIN_PACKED(dst, src)                           \
 do {                                                           \
@@ -266,7 +266,7 @@ int lttng_check_tracing_group(void)
        }
 
        /* Alloc group list of the right size */
-       grp_list = (gid_t *) zmalloc(grp_list_size * sizeof(gid_t));
+       grp_list = calloc<gid_t>(grp_list_size);
        if (!grp_list) {
                PERROR("malloc");
                goto end;
@@ -500,7 +500,7 @@ static int recv_sessiond_optional_data(size_t len, void **user_buf,
        size_t *user_len)
 {
        int ret = 0;
-       void *buf = NULL;
+       char *buf = NULL;
 
        if (len) {
                if (!user_len) {
@@ -508,7 +508,7 @@ static int recv_sessiond_optional_data(size_t len, void **user_buf,
                        goto end;
                }
 
-               buf = zmalloc(len);
+               buf = zmalloc<char>(len);
                if (!buf) {
                        ret = -ENOMEM;
                        goto end;
@@ -729,7 +729,7 @@ struct lttng_handle *lttng_create_handle(const char *session_name,
        int ret;
        struct lttng_handle *handle = NULL;
 
-       handle = (lttng_handle *) zmalloc(sizeof(struct lttng_handle));
+       handle = zmalloc<lttng_handle>();
        if (handle == NULL) {
                PERROR("malloc handle");
                goto end;
@@ -1576,13 +1576,13 @@ int lttng_enable_channel(struct lttng_handle *handle,
        /* Populate the channel extended attribute if necessary. */
        if (!channel->attr.extended.ptr) {
                struct lttng_channel_extended *extended =
-                               (struct lttng_channel_extended *) zmalloc(
-                                               sizeof(*extended));
+                               zmalloc<lttng_channel_extended>();
 
                if (!extended) {
                        ret = -LTTNG_ERR_NOMEM;
                        goto end;
                }
+
                lttng_channel_set_default_extended_attr(
                                &handle->domain, extended);
                channel->attr.extended.ptr = extended;
This page took 0.024871 seconds and 4 git commands to generate.