X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Futils.c;h=2ae586b512a7117c4ed5d761c84a93283ad679c2;hp=978af5883e2fe0b532897379ca0bd3486ddf7e3b;hb=refs%2Fheads%2Fsow-2019-0002-rev1;hpb=348a81dcf7b6944b10a813d93dcaf86fdb5194f6 diff --git a/src/bin/lttng-sessiond/utils.c b/src/bin/lttng-sessiond/utils.c index 978af5883..2ae586b51 100644 --- a/src/bin/lttng-sessiond/utils.c +++ b/src/bin/lttng-sessiond/utils.c @@ -1,19 +1,9 @@ /* - * Copyright (C) 2011 - David Goulet - * Mathieu Desnoyers + * Copyright (C) 2011 David Goulet + * Copyright (C) 2011 Mathieu Desnoyers * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2 only, - * as published by the Free Software Foundation. + * SPDX-License-Identifier: GPL-2.0-only * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #define _LGPL_SOURCE @@ -108,3 +98,26 @@ const char *consumer_output_get_base_path(const struct consumer_output *output) output->dst.session_root_path : output->dst.net.base_dir; } + +/* + * Allocate a filter and copy the given original filter. + * + * Return allocated filter or NULL on error. + */ +struct lttng_filter_bytecode *copy_filter_bytecode( + const struct lttng_filter_bytecode *orig_f) +{ + struct lttng_filter_bytecode *filter = NULL; + + /* Copy filter bytecode */ + filter = zmalloc(sizeof(*filter) + orig_f->len); + if (!filter) { + PERROR("zmalloc alloc filter bytecode"); + goto error; + } + + memcpy(filter, orig_f, sizeof(*filter) + orig_f->len); + +error: + return filter; +}