Add type-checked versions of allocation and deallocations functions
[lttng-tools.git] / src / common / uri.cpp
index 98ff2b471b0d87b3c9f3ae4dea8c449e83ae291e..8e663c46a732116b84c9e5c20615c6c018354034 100644 (file)
@@ -7,16 +7,16 @@
 
 #define _LGPL_SOURCE
 #include <arpa/inet.h>
-#include <common/compat/netdb.h>
+#include <common/compat/netdb.hpp>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/socket.h>
 
-#include <common/common.h>
-#include <common/defaults.h>
-#include <common/utils.h>
+#include <common/common.hpp>
+#include <common/defaults.hpp>
+#include <common/utils.hpp>
 
-#include "uri.h"
+#include "uri.hpp"
 
 #define LOOPBACK_ADDR_IPV4 "127.0.0.1"
 #define LOOPBACK_ADDR_IPV6 "::1"
@@ -43,7 +43,7 @@ static const struct uri_proto proto_uri[] = {
        { .name = "tcp4", .leading_string = "tcp4://", .code = P_TCP, .type = LTTNG_TCP, .dtype = LTTNG_DST_IPV4 },
        { .name = "tcp6", .leading_string = "tcp6://", .code = P_TCP6, .type = LTTNG_TCP, .dtype = LTTNG_DST_IPV6 },
        /* Invalid proto marking the end of the array. */
-       { 0 }
+       {}
 };
 
 /*
@@ -306,7 +306,7 @@ ssize_t uri_parse(const char *str_uri, struct lttng_uri **uris)
        }
 
        /* Allocate URI array */
-       tmp_uris = (lttng_uri *) zmalloc(sizeof(struct lttng_uri) * size);
+       tmp_uris = calloc<lttng_uri>(size);
        if (tmp_uris == NULL) {
                PERROR("zmalloc uri");
                goto error;
@@ -634,7 +634,7 @@ ssize_t uri_parse_str_urls(const char *ctrl_url, const char *data_url,
                goto error;
        }
 
-       tmp_uris = (lttng_uri *) zmalloc(sizeof(struct lttng_uri) * uri_count);
+       tmp_uris = calloc<lttng_uri>(uri_count);
        if (tmp_uris == NULL) {
                PERROR("zmalloc uris");
                goto error;
This page took 0.036385 seconds and 4 git commands to generate.