/*
- * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2011 EfficiOS Inc.
* Copyright (C) 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
* Copyright (C) 2020 Francis Deslauriers <francis.deslauriers@efficios.com>
*
- * SPDX-License-Identifier: GPL-2.0-only
+ * SPDX-License-Identifier: LGPL-2.1-only
*
*/
#include <lttng/constant.h>
-#include <common/compat/errno.h>
-#include "error.h"
-#include "macros.h"
-#include "spawn-viewer.h"
-
-
-static const char *babeltrace_bin = CONFIG_BABELTRACE_BIN;
-static const char *babeltrace2_bin = CONFIG_BABELTRACE2_BIN;
-
-/*
- * This is needed for each viewer since we are using execvp().
- */
-static const char *babeltrace_opts[] = { "babeltrace" };
-static const char *babeltrace2_opts[] = { "babeltrace2" };
+#include <common/compat/errno.hpp>
+#include "error.hpp"
+#include "macros.hpp"
+#include "spawn-viewer.hpp"
/*
* Type is also use as the index in the viewers array. So please, make sure
VIEWER_USER_DEFINED = 2,
};
-static const struct viewer {
+namespace {
+const char *babeltrace_bin = CONFIG_BABELTRACE_BIN;
+const char *babeltrace2_bin = CONFIG_BABELTRACE2_BIN;
+
+/*
+ * This is needed for each viewer since we are using execvp().
+ */
+const char *babeltrace_opts[] = { "babeltrace" };
+const char *babeltrace2_opts[] = { "babeltrace2" };
+
+const struct viewer {
const char *exec_name;
enum viewer_type type;
} viewers[] = {
{ "babeltrace2", VIEWER_BABELTRACE2 },
{ NULL, VIEWER_USER_DEFINED },
};
+} /* namespace */
static const struct viewer *parse_viewer_option(const char *opt_viewer)
{
} while (*token != '\0');
/* Add two here for the NULL terminating element and trace path */
- argv = (char **) zmalloc(sizeof(char *) * (num_opts + 2));
+ argv = calloc<char *>(num_opts + 2);
if (argv == NULL) {
goto error;
}
const char *trace_path, bool opt_live_mode)
{
char **argv;
- size_t size, mem_len;
+ size_t mem_len;
/* Add one for the NULL terminating element. */
mem_len = opts_len + 1;
mem_len += 1;
}
- size = sizeof(char *) * mem_len;
-
- /* Add two here for the trace_path and the NULL terminating element. */
- argv = (char **) zmalloc(size);
+ argv = calloc<char *>(mem_len);
if (argv == NULL) {
goto error;
}