X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Furi.cpp;h=3b74928b401cc469a9b2dca2f8f205b3746a1d71;hb=88277a52069ed0135254ce29da617ebb6ecddbb8;hp=b1c2c63d09bcc28475445cfd5f998076bfc0d245;hpb=a6bc4ca9d659caf016ef932fcd944029737ac57c;p=lttng-tools.git diff --git a/src/common/uri.cpp b/src/common/uri.cpp index b1c2c63d0..3b74928b4 100644 --- a/src/common/uri.cpp +++ b/src/common/uri.cpp @@ -1,22 +1,22 @@ /* * Copyright (C) 2012 David Goulet * - * SPDX-License-Identifier: GPL-2.0-only + * SPDX-License-Identifier: LGPL-2.1-only * */ #define _LGPL_SOURCE #include -#include +#include #include #include #include -#include -#include -#include +#include +#include +#include -#include "uri.h" +#include "uri.hpp" #define LOOPBACK_ADDR_IPV4 "127.0.0.1" #define LOOPBACK_ADDR_IPV6 "::1" @@ -25,6 +25,7 @@ enum uri_proto_code { P_NET, P_NET6, P_FILE, P_TCP, P_TCP6, }; +namespace { struct uri_proto { const char *name; const char *leading_string; @@ -34,7 +35,7 @@ struct uri_proto { }; /* Supported protocols */ -static const struct uri_proto proto_uri[] = { +const struct uri_proto proto_uri[] = { { .name = "file", .leading_string = "file://", .code = P_FILE, .type = LTTNG_PROTO_TYPE_NONE, .dtype = LTTNG_DST_PATH }, { .name = "net", .leading_string = "net://", .code = P_NET, .type = LTTNG_TCP, .dtype = LTTNG_DST_IPV4 }, { .name = "net4", .leading_string = "net4://", .code = P_NET, .type = LTTNG_TCP, .dtype = LTTNG_DST_IPV4 }, @@ -43,8 +44,9 @@ 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 } + {} }; +} /* namespace */ /* * Return pointer to the character in s matching one of the characters in @@ -306,7 +308,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(size); if (tmp_uris == NULL) { PERROR("zmalloc uri"); goto error; @@ -634,7 +636,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(uri_count); if (tmp_uris == NULL) { PERROR("zmalloc uris"); goto error;