From 3d92f6a7dd862f946b56172cb6a50b2b420ce144 Mon Sep 17 00:00:00 2001 From: Attila Szakacs Date: Wed, 30 Oct 2024 15:42:29 +0100 Subject: [PATCH] filterx: add init() and deinit() for every necessary expr Signed-off-by: Attila Szakacs --- lib/filterx/expr-compound.c | 38 +++++++++++ lib/filterx/expr-condition.c | 38 +++++++++++ lib/filterx/expr-function.c | 62 ++++++++++++++++++ lib/filterx/expr-function.h | 4 ++ lib/filterx/expr-generator.c | 44 +++++++++++++ lib/filterx/expr-generator.h | 2 + lib/filterx/expr-get-subscript.c | 29 +++++++++ lib/filterx/expr-getattr.c | 21 ++++++ lib/filterx/expr-literal-generator.c | 61 +++++++++++++++++ lib/filterx/expr-plus-generator.c | 27 ++++++++ lib/filterx/expr-regexp.c | 65 +++++++++++++++++++ lib/filterx/expr-set-subscript.c | 37 +++++++++++ lib/filterx/expr-setattr.c | 29 +++++++++ lib/filterx/expr-unset.c | 38 +++++++++++ lib/filterx/filterx-expr.c | 48 ++++++++++++++ lib/filterx/filterx-expr.h | 4 ++ lib/filterx/filterx-metrics-labels.c | 54 +++++++++++++++ lib/filterx/filterx-metrics-labels.h | 2 + lib/filterx/filterx-metrics.c | 22 +++++++ lib/filterx/filterx-metrics.h | 2 + lib/filterx/func-flatten.c | 22 +++++++ lib/filterx/func-istype.c | 21 ++++++ lib/filterx/func-str.c | 29 +++++++++ lib/filterx/func-unset-empties.c | 22 +++++++ modules/cef/event-format-parser.c | 21 ++++++ modules/csvparser/filterx-func-format-csv.c | 29 +++++++++ modules/csvparser/filterx-func-parse-csv.c | 36 ++++++++++ modules/kvformat/filterx-func-format-kv.c | 22 +++++++ modules/kvformat/filterx-func-parse-kv.c | 21 ++++++ .../filterx/func-update-metric.c | 28 ++++++++ modules/xml/filterx-parse-xml.c | 22 +++++++ 31 files changed, 900 insertions(+) diff --git a/lib/filterx/expr-compound.c b/lib/filterx/expr-compound.c index 9a0bc144a0..b324894c6e 100644 --- a/lib/filterx/expr-compound.c +++ b/lib/filterx/expr-compound.c @@ -129,6 +129,42 @@ _eval(FilterXExpr *s) return result; } +static gboolean +_init(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXCompoundExpr *self = (FilterXCompoundExpr *) s; + + for (gint i = 0; i < self->exprs->len; i++) + { + FilterXExpr *expr = g_ptr_array_index(self->exprs, i); + if (!filterx_expr_init(expr, cfg)) + { + for (gint j = 0; j < i; j++) + { + expr = g_ptr_array_index(self->exprs, j); + filterx_expr_deinit(expr, cfg); + } + return FALSE; + } + } + + return filterx_expr_init_method(s, cfg); +} + +static void +_deinit(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXCompoundExpr *self = (FilterXCompoundExpr *) s; + + for (gint i = 0; i < self->exprs->len; i++) + { + FilterXExpr *expr = g_ptr_array_index(self->exprs, i); + filterx_expr_deinit(expr, cfg); + } + + filterx_expr_deinit_method(s, cfg); +} + static void _free(FilterXExpr *s) { @@ -165,6 +201,8 @@ filterx_compound_expr_new(gboolean return_value_of_last_expr) filterx_expr_init_instance(&self->super); self->super.eval = _eval; + self->super.init = _init; + self->super.deinit = _deinit; self->super.free_fn = _free; self->exprs = g_ptr_array_new_with_free_func((GDestroyNotify) filterx_expr_unref); self->return_value_of_last_expr = return_value_of_last_expr; diff --git a/lib/filterx/expr-condition.c b/lib/filterx/expr-condition.c index 1e9f8392c2..8473a49c8a 100644 --- a/lib/filterx/expr-condition.c +++ b/lib/filterx/expr-condition.c @@ -35,6 +35,42 @@ struct _FilterXConditional FilterXExpr *false_branch; }; +static gboolean +_init(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXConditional *self = (FilterXConditional *) s; + + if (!filterx_expr_init(self->condition, cfg)) + return FALSE; + + if (!filterx_expr_init(self->true_branch, cfg)) + { + filterx_expr_deinit(self->condition, cfg); + return FALSE; + } + + if (!filterx_expr_init(self->false_branch, cfg)) + { + filterx_expr_deinit(self->condition, cfg); + filterx_expr_deinit(self->true_branch, cfg); + return FALSE; + } + + return filterx_expr_init_method(s, cfg); +} + + +static void +_deinit(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXConditional *self = (FilterXConditional *) s; + + filterx_expr_deinit(self->condition, cfg); + filterx_expr_deinit(self->true_branch, cfg); + filterx_expr_deinit(self->false_branch, cfg); + filterx_expr_deinit_method(s, cfg); +} + static void _free(FilterXExpr *s) { @@ -119,6 +155,8 @@ filterx_conditional_new(FilterXExpr *condition) FilterXConditional *self = g_new0(FilterXConditional, 1); filterx_expr_init_instance(&self->super); self->super.eval = _eval; + self->super.init = _init; + self->super.deinit = _deinit; self->super.free_fn = _free; self->super.suppress_from_trace = TRUE; self->condition = condition; diff --git a/lib/filterx/expr-function.c b/lib/filterx/expr-function.c index e5a05adcc0..408051995c 100644 --- a/lib/filterx/expr-function.c +++ b/lib/filterx/expr-function.c @@ -133,6 +133,42 @@ _simple_eval(FilterXExpr *s) return res; } +static gboolean +_simple_init(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXSimpleFunction *self = (FilterXSimpleFunction *) s; + + for (guint64 i = 0; i < self->args->len; i++) + { + FilterXExpr *arg = g_ptr_array_index(self->args, i); + if (!filterx_expr_init(arg, cfg)) + { + for (gint j = 0; j < i; j++) + { + arg = g_ptr_array_index(self->args, j); + filterx_expr_deinit(arg, cfg); + } + return FALSE; + } + } + + return filterx_function_init_method(&self->super, cfg); +} + +static void +_simple_deinit(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXSimpleFunction *self = (FilterXSimpleFunction *) s; + + for (guint64 i = 0; i < self->args->len; i++) + { + FilterXExpr *arg = g_ptr_array_index(self->args, i); + filterx_expr_deinit(arg, cfg); + } + + filterx_function_deinit_method(&self->super, cfg); +} + static void _simple_free(FilterXExpr *s) { @@ -169,6 +205,8 @@ filterx_simple_function_new(const gchar *function_name, FilterXFunctionArgs *arg filterx_function_init_instance(&self->super, function_name); self->super.super.eval = _simple_eval; + self->super.super.init = _simple_init; + self->super.super.deinit = _simple_deinit; self->super.super.free_fn = _simple_free; self->function_proto = function_proto; @@ -186,6 +224,18 @@ filterx_simple_function_new(const gchar *function_name, FilterXFunctionArgs *arg return NULL; } +gboolean +filterx_function_init_method(FilterXFunction *s, GlobalConfig *cfg) +{ + return filterx_expr_init_method(&s->super, cfg); +} + +void +filterx_function_deinit_method(FilterXFunction *s, GlobalConfig *cfg) +{ + filterx_expr_deinit_method(&s->super, cfg); +} + void filterx_function_free_method(FilterXFunction *s) { @@ -208,6 +258,18 @@ filterx_function_init_instance(FilterXFunction *s, const gchar *function_name) s->super.free_fn = _function_free; } +gboolean +filterx_generator_function_init_method(FilterXGeneratorFunction *s, GlobalConfig *cfg) +{ + return filterx_generator_init_method(&s->super.super, cfg); +} + +void +filterx_generator_function_deinit_method(FilterXGeneratorFunction *s, GlobalConfig *cfg) +{ + filterx_generator_deinit_method(&s->super.super, cfg); +} + void filterx_generator_function_free_method(FilterXGeneratorFunction *s) { diff --git a/lib/filterx/expr-function.h b/lib/filterx/expr-function.h index 076bc73fa1..819e0b736e 100644 --- a/lib/filterx/expr-function.h +++ b/lib/filterx/expr-function.h @@ -69,7 +69,11 @@ enum FilterXFunctionError }; void filterx_function_init_instance(FilterXFunction *s, const gchar *function_name); +gboolean filterx_function_init_method(FilterXFunction *s, GlobalConfig *cfg); +void filterx_function_deinit_method(FilterXFunction *s, GlobalConfig *cfg); void filterx_function_free_method(FilterXFunction *s); +gboolean filterx_generator_function_init_method(FilterXGeneratorFunction *s, GlobalConfig *cfg); +void filterx_generator_function_deinit_method(FilterXGeneratorFunction *s, GlobalConfig *cfg); void filterx_generator_function_init_instance(FilterXGeneratorFunction *s, const gchar *function_name); void filterx_generator_function_free_method(FilterXGeneratorFunction *s); diff --git a/lib/filterx/expr-generator.c b/lib/filterx/expr-generator.c index b39f0b2933..378c989a57 100644 --- a/lib/filterx/expr-generator.c +++ b/lib/filterx/expr-generator.c @@ -59,10 +59,32 @@ void filterx_generator_init_instance(FilterXExpr *s) { filterx_expr_init_instance(s); + s->init = filterx_generator_init_method; + s->deinit = filterx_generator_deinit_method; s->eval = _eval; s->ignore_falsy_result = TRUE; } +gboolean +filterx_generator_init_method(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXExprGenerator *self = (FilterXExprGenerator *) s; + + if (!filterx_expr_init(self->fillable, cfg)) + return FALSE; + + return filterx_expr_init_method(s, cfg); +} + +void +filterx_generator_deinit_method(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXExprGenerator *self = (FilterXExprGenerator *) s; + + filterx_expr_deinit(self->fillable, cfg); + filterx_expr_deinit_method(s, cfg); +} + void filterx_generator_free_method(FilterXExpr *s) { @@ -87,6 +109,26 @@ _create_container_eval(FilterXExpr *s) return self->generator->create_container(self->generator, self->fillable_parent); } +static gboolean +_create_container_init(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXExprGeneratorCreateContainer *self = (FilterXExprGeneratorCreateContainer *) s; + + if (!filterx_expr_init(self->fillable_parent, cfg)) + return FALSE; + + return filterx_expr_init_method(s, cfg); +} + +static void +_create_container_deinit(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXExprGeneratorCreateContainer *self = (FilterXExprGeneratorCreateContainer *) s; + + filterx_expr_deinit(self->fillable_parent, cfg); + filterx_expr_deinit_method(s, cfg); +} + static void _create_container_free(FilterXExpr *s) { @@ -130,6 +172,8 @@ filterx_generator_create_container_new(FilterXExpr *g, FilterXExpr *fillable_par filterx_expr_init_instance(&self->super); self->generator = (FilterXExprGenerator *) g; self->fillable_parent = fillable_parent; + self->super.init = _create_container_init; + self->super.deinit = _create_container_deinit; self->super.eval = _create_container_eval; self->super.free_fn = _create_container_free; diff --git a/lib/filterx/expr-generator.h b/lib/filterx/expr-generator.h index 72688dfecd..f3026c448c 100644 --- a/lib/filterx/expr-generator.h +++ b/lib/filterx/expr-generator.h @@ -37,6 +37,8 @@ struct FilterXExprGenerator_ void filterx_generator_set_fillable(FilterXExpr *s, FilterXExpr *fillable); void filterx_generator_init_instance(FilterXExpr *s); +gboolean filterx_generator_init_method(FilterXExpr *s, GlobalConfig *cfg); +void filterx_generator_deinit_method(FilterXExpr *s, GlobalConfig *cfg); void filterx_generator_free_method(FilterXExpr *s); gboolean filterx_expr_is_generator(FilterXExpr *s); diff --git a/lib/filterx/expr-get-subscript.c b/lib/filterx/expr-get-subscript.c index 69dc2a4df9..6ccee3c26a 100644 --- a/lib/filterx/expr-get-subscript.c +++ b/lib/filterx/expr-get-subscript.c @@ -103,6 +103,33 @@ _unset(FilterXExpr *s) return result; } +static gboolean +_init(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXGetSubscript *self = (FilterXGetSubscript *) s; + + if (!filterx_expr_init(self->operand, cfg)) + return FALSE; + + if (!filterx_expr_init(self->key, cfg)) + { + filterx_expr_deinit(self->operand, cfg); + return FALSE; + } + + return filterx_expr_init_method(s, cfg); +} + +static void +_deinit(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXGetSubscript *self = (FilterXGetSubscript *) s; + + filterx_expr_deinit(self->operand, cfg); + filterx_expr_deinit(self->key, cfg); + filterx_expr_deinit_method(s, cfg); +} + static void _free(FilterXExpr *s) { @@ -122,6 +149,8 @@ filterx_get_subscript_new(FilterXExpr *operand, FilterXExpr *key) self->super.eval = _eval; self->super.is_set = _isset; self->super.unset = _unset; + self->super.init = _init; + self->super.deinit = _deinit; self->super.free_fn = _free; self->operand = operand; self->key = key; diff --git a/lib/filterx/expr-getattr.c b/lib/filterx/expr-getattr.c index ada4d74ff0..781e64cfc5 100644 --- a/lib/filterx/expr-getattr.c +++ b/lib/filterx/expr-getattr.c @@ -90,6 +90,25 @@ _isset(FilterXExpr *s) return result; } +static gboolean +_init(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXGetAttr *self = (FilterXGetAttr *) s; + + if (!filterx_expr_init(self->operand, cfg)) + return FALSE; + + return filterx_expr_init_method(s, cfg); +} + +static void +_deinit(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXGetAttr *self = (FilterXGetAttr *) s; + + filterx_expr_deinit(self->operand, cfg); + filterx_expr_deinit_method(s, cfg); +} static void _free(FilterXExpr *s) @@ -110,6 +129,8 @@ filterx_getattr_new(FilterXExpr *operand, FilterXString *attr_name) self->super.eval = _eval; self->super.unset = _unset; self->super.is_set = _isset; + self->super.init = _init; + self->super.deinit = _deinit; self->super.free_fn = _free; self->operand = operand; diff --git a/lib/filterx/expr-literal-generator.c b/lib/filterx/expr-literal-generator.c index 61eea5da50..e11d259016 100644 --- a/lib/filterx/expr-literal-generator.c +++ b/lib/filterx/expr-literal-generator.c @@ -44,6 +44,28 @@ filterx_literal_generator_elem_new(FilterXExpr *key, FilterXExpr *value, gboolea return self; } +static gboolean +_literal_generator_elem_init(FilterXLiteralGeneratorElem *self, GlobalConfig *cfg) +{ + if (!filterx_expr_init(self->key, cfg)) + return FALSE; + + if (!filterx_expr_init(self->value, cfg)) + { + filterx_expr_deinit(self->key, cfg); + return FALSE; + } + + return TRUE; +} + +static void +_literal_generator_elem_deinit(FilterXLiteralGeneratorElem *self, GlobalConfig *cfg) +{ + filterx_expr_deinit(self->key, cfg); + filterx_expr_deinit(self->value, cfg); +} + static void _literal_generator_elem_free(FilterXLiteralGeneratorElem *self) { @@ -118,6 +140,43 @@ _literal_generator_generate(FilterXExprGenerator *s, FilterXObject *fillable) return _eval_elements(fillable, self->elements); } +static gboolean +_literal_generator_init(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXExprLiteralGenerator *self = (FilterXExprLiteralGenerator *) s; + + for (GList *link = self->elements; link; link = link->next) + { + FilterXLiteralGeneratorElem *elem = (FilterXLiteralGeneratorElem *) link->data; + + if (!_literal_generator_elem_init(elem, cfg)) + { + for (GList *deinit_link = self->elements; deinit_link != link; deinit_link = deinit_link->next) + { + elem = (FilterXLiteralGeneratorElem *) deinit_link->data; + _literal_generator_elem_deinit(elem, cfg); + } + return FALSE; + } + } + + return filterx_generator_init_method(s, cfg); +} + +static void +_literal_generator_deinit(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXExprLiteralGenerator *self = (FilterXExprLiteralGenerator *) s; + + for (GList *link = self->elements; link; link = link->next) + { + FilterXLiteralGeneratorElem *elem = (FilterXLiteralGeneratorElem *) link->data; + _literal_generator_elem_deinit(elem, cfg); + } + + filterx_generator_deinit_method(s, cfg); +} + void _literal_generator_free(FilterXExpr *s) { @@ -132,6 +191,8 @@ _literal_generator_init_instance(FilterXExprLiteralGenerator *self) { filterx_generator_init_instance(&self->super.super); self->super.generate = _literal_generator_generate; + self->super.super.init = _literal_generator_init; + self->super.super.deinit = _literal_generator_deinit; self->super.super.free_fn = _literal_generator_free; } diff --git a/lib/filterx/expr-plus-generator.c b/lib/filterx/expr-plus-generator.c index f9fda257ff..a0677ab657 100644 --- a/lib/filterx/expr-plus-generator.c +++ b/lib/filterx/expr-plus-generator.c @@ -100,6 +100,31 @@ _expr_plus_generator_create_container(FilterXExprGenerator *s, FilterXExpr *fill return generator->create_container(generator, fillable_parent); } +static gboolean +_expr_plus_generator_init(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXOperatorPlusGenerator *self = (FilterXOperatorPlusGenerator *) s; + + if (!filterx_expr_init(self->lhs, cfg)) + return FALSE; + + if (!filterx_expr_init(self->rhs, cfg)) + { + filterx_expr_deinit(self->lhs, cfg); + return FALSE; + } + return filterx_generator_init_method(s, cfg); +} + +static void +_expr_plus_generator_deinit(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXOperatorPlusGenerator *self = (FilterXOperatorPlusGenerator *) s; + filterx_expr_deinit(self->lhs, cfg); + filterx_expr_deinit(self->rhs, cfg); + filterx_generator_deinit_method(s, cfg); +} + static void _expr_plus_generator_free(FilterXExpr *s) { @@ -117,6 +142,8 @@ filterx_operator_plus_generator_new(FilterXExpr *lhs, FilterXExpr *rhs) self->lhs = lhs; self->rhs = rhs; self->super.generate = _expr_plus_generator_generate; + self->super.super.init = _expr_plus_generator_init; + self->super.super.deinit = _expr_plus_generator_deinit; self->super.super.free_fn = _expr_plus_generator_free; self->super.create_container = _expr_plus_generator_create_container; diff --git a/lib/filterx/expr-regexp.c b/lib/filterx/expr-regexp.c index 821956bcaf..cb8df99ca8 100644 --- a/lib/filterx/expr-regexp.c +++ b/lib/filterx/expr-regexp.c @@ -315,6 +315,26 @@ _regexp_match_eval(FilterXExpr *s) return result; } +static gboolean +_regexp_match_init(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXExprRegexpMatch *self = (FilterXExprRegexpMatch *) s; + + if (!filterx_expr_init(self->lhs, cfg)) + return FALSE; + + return filterx_expr_init_method(s, cfg); +} + +static void +_regexp_match_deinit(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXExprRegexpMatch *self = (FilterXExprRegexpMatch *) s; + + filterx_expr_deinit(self->lhs, cfg); + filterx_expr_deinit_method(s, cfg); +} + static void _regexp_match_free(FilterXExpr *s) { @@ -334,6 +354,8 @@ filterx_expr_regexp_match_new(FilterXExpr *lhs, const gchar *pattern) filterx_expr_init_instance(&self->super); self->super.eval = _regexp_match_eval; + self->super.init = _regexp_match_init; + self->super.deinit = _regexp_match_deinit; self->super.free_fn = _regexp_match_free; self->lhs = lhs; @@ -403,6 +425,26 @@ _regexp_search_generator_create_container(FilterXExprGenerator *s, FilterXExpr * return filterx_generator_create_list_container(s, fillable_parent); } +static gboolean +_regexp_search_generator_init(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXExprRegexpSearchGenerator *self = (FilterXExprRegexpSearchGenerator *) s; + + if (!filterx_expr_init(self->lhs, cfg)) + return FALSE; + + return filterx_generator_init_method(s, cfg); +} + +static void +_regexp_search_generator_deinit(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXExprRegexpSearchGenerator *self = (FilterXExprRegexpSearchGenerator *) s; + + filterx_expr_deinit(self->lhs, cfg); + filterx_generator_deinit_method(s, cfg); +} + static void _regexp_search_generator_free(FilterXExpr *s) { @@ -454,6 +496,8 @@ filterx_generator_function_regexp_search_new(FilterXFunctionArgs *args, GError * filterx_generator_function_init_instance(&self->super, "regexp_search"); self->super.super.generate = _regexp_search_generator_generate; + self->super.super.super.init = _regexp_search_generator_init; + self->super.super.super.deinit = _regexp_search_generator_deinit; self->super.super.super.free_fn = _regexp_search_generator_free; self->super.super.create_container = _regexp_search_generator_create_container; @@ -677,6 +721,25 @@ _extract_subst_args(FilterXFuncRegexpSubst *self, FilterXFunctionArgs *args, GEr return TRUE; } +static gboolean +_subst_init(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXFuncRegexpSubst *self = (FilterXFuncRegexpSubst *) s; + + if (!filterx_expr_init(self->string_expr, cfg)) + return FALSE; + + return filterx_function_init_method(&self->super, cfg); +} + +static void +_subst_deinit(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXFuncRegexpSubst *self = (FilterXFuncRegexpSubst *) s; + filterx_expr_deinit(self->string_expr, cfg); + filterx_function_deinit_method(&self->super, cfg); +} + static void _subst_free(FilterXExpr *s) { @@ -701,6 +764,8 @@ filterx_function_regexp_subst_new(FilterXFunctionArgs *args, GError **error) FilterXFuncRegexpSubst *self = g_new0(FilterXFuncRegexpSubst, 1); filterx_function_init_instance(&self->super, "regexp_subst"); self->super.super.eval = _subst_eval; + self->super.super.init = _subst_init; + self->super.super.deinit = _subst_deinit; self->super.super.free_fn = _subst_free; _opts_init(&self->opts); diff --git a/lib/filterx/expr-set-subscript.c b/lib/filterx/expr-set-subscript.c index 3901d164c9..aabecd8497 100644 --- a/lib/filterx/expr-set-subscript.c +++ b/lib/filterx/expr-set-subscript.c @@ -93,6 +93,41 @@ _eval(FilterXExpr *s) return result; } +static gboolean +_init(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXSetSubscript *self = (FilterXSetSubscript *) s; + + if (!filterx_expr_init(self->object, cfg)) + return FALSE; + + if (!filterx_expr_init(self->new_value, cfg)) + { + filterx_expr_deinit(self->object, cfg); + return FALSE; + } + + if (!filterx_expr_init(self->key, cfg)) + { + filterx_expr_deinit(self->object, cfg); + filterx_expr_deinit(self->new_value, cfg); + return FALSE; + } + + return filterx_expr_init_method(s, cfg); +} + +static void +_deinit(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXSetSubscript *self = (FilterXSetSubscript *) s; + + filterx_expr_deinit(self->object, cfg); + filterx_expr_deinit(self->new_value, cfg); + filterx_expr_deinit(self->key, cfg); + filterx_expr_deinit_method(s, cfg); +} + static void _free(FilterXExpr *s) { @@ -111,6 +146,8 @@ filterx_set_subscript_new(FilterXExpr *object, FilterXExpr *key, FilterXExpr *ne filterx_expr_init_instance(&self->super); self->super.eval = _eval; + self->super.init = _init; + self->super.deinit = _deinit; self->super.free_fn = _free; self->object = object; self->key = key; diff --git a/lib/filterx/expr-setattr.c b/lib/filterx/expr-setattr.c index bd50842928..63ca218470 100644 --- a/lib/filterx/expr-setattr.c +++ b/lib/filterx/expr-setattr.c @@ -80,6 +80,33 @@ _eval(FilterXExpr *s) return result; } +static gboolean +_init(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXSetAttr *self = (FilterXSetAttr *) s; + + if (!filterx_expr_init(self->object, cfg)) + return FALSE; + + if (!filterx_expr_init(self->new_value, cfg)) + { + filterx_expr_deinit(self->object, cfg); + return FALSE; + } + + return filterx_expr_init_method(s, cfg); +} + +static void +_deinit(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXSetAttr *self = (FilterXSetAttr *) s; + + filterx_expr_deinit(self->object, cfg); + filterx_expr_deinit(self->new_value, cfg); + filterx_expr_deinit_method(s, cfg); +} + static void _free(FilterXExpr *s) { @@ -99,6 +126,8 @@ filterx_setattr_new(FilterXExpr *object, FilterXString *attr_name, FilterXExpr * filterx_expr_init_instance(&self->super); self->super.eval = _eval; + self->super.init = _init; + self->super.deinit = _deinit; self->super.free_fn = _free; self->object = object; diff --git a/lib/filterx/expr-unset.c b/lib/filterx/expr-unset.c index 1fb2429420..b3dfa97a5b 100644 --- a/lib/filterx/expr-unset.c +++ b/lib/filterx/expr-unset.c @@ -46,6 +46,42 @@ _eval(FilterXExpr *s) return filterx_boolean_new(TRUE); } +static gboolean +_init(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXExprUnset *self = (FilterXExprUnset *) s; + + for (guint i = 0; i < self->exprs->len; i++) + { + FilterXExpr *expr = (FilterXExpr *) g_ptr_array_index(self->exprs, i); + if (!filterx_expr_init(expr, cfg)) + { + for (guint j = 0; j < i; j++) + { + expr = g_ptr_array_index(self->exprs, i); + filterx_expr_deinit(expr, cfg); + } + return FALSE; + } + } + + return filterx_function_init_method(&self->super, cfg); +} + +static void +_deinit(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXExprUnset *self = (FilterXExprUnset *) s; + + for (guint i = 0; i < self->exprs->len; i++) + { + FilterXExpr *expr = (FilterXExpr *) g_ptr_array_index(self->exprs, i); + filterx_expr_deinit(expr, cfg); + } + + filterx_function_deinit_method(&self->super, cfg); +} + static void _free(FilterXExpr *s) { @@ -62,6 +98,8 @@ filterx_function_unset_new(FilterXFunctionArgs *args, GError **error) filterx_function_init_instance(&self->super, "unset"); self->super.super.eval = _eval; + self->super.super.init = _init; + self->super.super.deinit = _deinit; self->super.super.free_fn = _free; self->exprs = g_ptr_array_new_full(filterx_function_args_len(args), (GDestroyNotify) filterx_expr_unref); diff --git a/lib/filterx/filterx-expr.c b/lib/filterx/filterx-expr.c index ad54cdb972..de72809210 100644 --- a/lib/filterx/filterx-expr.c +++ b/lib/filterx/filterx-expr.c @@ -119,6 +119,26 @@ filterx_expr_unref(FilterXExpr *self) } } +gboolean +filterx_unary_op_init_method(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXUnaryOp *self = (FilterXUnaryOp *) s; + + if (!filterx_expr_init(self->operand, cfg)) + return FALSE; + + return filterx_expr_init_method(s, cfg); +} + +void +filterx_unary_op_deinit_method(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXUnaryOp *self = (FilterXUnaryOp *) s; + + filterx_expr_deinit(self->operand, cfg); + filterx_expr_deinit_method(s, cfg); +} + void filterx_unary_op_free_method(FilterXExpr *s) { @@ -132,6 +152,8 @@ void filterx_unary_op_init_instance(FilterXUnaryOp *self, FilterXExpr *operand) { filterx_expr_init_instance(&self->super); + self->super.init = filterx_unary_op_init_method; + self->super.deinit = filterx_unary_op_deinit_method; self->super.free_fn = filterx_unary_op_free_method; self->operand = operand; } @@ -146,10 +168,36 @@ filterx_binary_op_free_method(FilterXExpr *s) filterx_expr_free_method(s); } +gboolean +filterx_binary_op_init_method(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXBinaryOp *self = (FilterXBinaryOp *) s; + + if (!filterx_expr_init(self->lhs, cfg)) + return FALSE; + + if (!filterx_expr_init(self->rhs, cfg)) + return FALSE; + + return filterx_expr_init_method(s, cfg); +} + +void +filterx_binary_op_deinit_method(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXBinaryOp *self = (FilterXBinaryOp *) s; + + filterx_expr_deinit(self->lhs, cfg); + filterx_expr_deinit(self->rhs, cfg); + filterx_expr_deinit_method(s, cfg); +} + void filterx_binary_op_init_instance(FilterXBinaryOp *self, FilterXExpr *lhs, FilterXExpr *rhs) { filterx_expr_init_instance(&self->super); + self->super.init = filterx_binary_op_init_method; + self->super.deinit = filterx_binary_op_deinit_method; self->super.free_fn = filterx_binary_op_free_method; g_assert(lhs); g_assert(rhs); diff --git a/lib/filterx/filterx-expr.h b/lib/filterx/filterx-expr.h index 1065a21778..d889c0aaad 100644 --- a/lib/filterx/filterx-expr.h +++ b/lib/filterx/filterx-expr.h @@ -187,6 +187,8 @@ typedef struct _FilterXUnaryOp FilterXExpr *operand; } FilterXUnaryOp; +gboolean filterx_unary_op_init_method(FilterXExpr *s, GlobalConfig *cfg); +void filterx_unary_op_deinit_method(FilterXExpr *s, GlobalConfig *cfg); void filterx_unary_op_free_method(FilterXExpr *s); void filterx_unary_op_init_instance(FilterXUnaryOp *self, FilterXExpr *operand); @@ -196,6 +198,8 @@ typedef struct _FilterXBinaryOp FilterXExpr *lhs, *rhs; } FilterXBinaryOp; +gboolean filterx_binary_op_init_method(FilterXExpr *s, GlobalConfig *cfg); +void filterx_binary_op_deinit_method(FilterXExpr *s, GlobalConfig *cfg); void filterx_binary_op_free_method(FilterXExpr *s); void filterx_binary_op_init_instance(FilterXBinaryOp *self, FilterXExpr *lhs, FilterXExpr *rhs); diff --git a/lib/filterx/filterx-metrics-labels.c b/lib/filterx/filterx-metrics-labels.c index 979f644cf8..44b1844d8a 100644 --- a/lib/filterx/filterx-metrics-labels.c +++ b/lib/filterx/filterx-metrics-labels.c @@ -98,6 +98,18 @@ _label_cmp(gconstpointer a, gconstpointer b) return strcmp(lhs->name, rhs->name); } +static gboolean +_label_init(FilterXMetricsLabel *self, GlobalConfig *cfg) +{ + return filterx_expr_init(self->value.expr, cfg); +} + +static void +_label_deinit(FilterXMetricsLabel *self, GlobalConfig *cfg) +{ + filterx_expr_deinit(self->value.expr, cfg); +} + static void _label_free(FilterXMetricsLabel *self) { @@ -286,6 +298,48 @@ filterx_metrics_labels_format(FilterXMetricsLabels *self, StatsClusterLabel **la return TRUE; } +gboolean +filterx_metrics_labels_init(FilterXMetricsLabels *self, GlobalConfig *cfg) +{ + if (!filterx_expr_init(self->expr, cfg)) + return FALSE; + + if (self->literal_labels) + { + for (guint i = 0; i < self->literal_labels->len; i++) + { + FilterXMetricsLabel *label = g_ptr_array_index(self->literal_labels, i); + if (!_label_init(label, cfg)) + { + for (guint j = 0; j < i; j++) + { + label = g_ptr_array_index(self->literal_labels, j); + _label_deinit(label, cfg); + } + filterx_expr_deinit(self->expr, cfg); + return FALSE; + } + } + } + + return TRUE; +} + +void +filterx_metrics_labels_deinit(FilterXMetricsLabels *self, GlobalConfig *cfg) +{ + filterx_expr_deinit(self->expr, cfg); + + if (self->literal_labels) + { + for (guint i = 0; i < self->literal_labels->len; i++) + { + FilterXMetricsLabel *label = g_ptr_array_index(self->literal_labels, i); + _label_deinit(label, cfg); + } + } +} + void filterx_metrics_labels_free(FilterXMetricsLabels *self) { diff --git a/lib/filterx/filterx-metrics-labels.h b/lib/filterx/filterx-metrics-labels.h index d17cfdcfa2..cbb5903b91 100644 --- a/lib/filterx/filterx-metrics-labels.h +++ b/lib/filterx/filterx-metrics-labels.h @@ -30,6 +30,8 @@ typedef struct _FilterXMetricsLabels FilterXMetricsLabels; FilterXMetricsLabels *filterx_metrics_labels_new(FilterXExpr *labels); +gboolean filterx_metrics_labels_init(FilterXMetricsLabels *self, GlobalConfig *cfg); +void filterx_metrics_labels_deinit(FilterXMetricsLabels *self, GlobalConfig *cfg); void filterx_metrics_labels_free(FilterXMetricsLabels *self); gboolean filterx_metrics_labels_format(FilterXMetricsLabels *self, StatsClusterLabel **labels, gsize *len); diff --git a/lib/filterx/filterx-metrics.c b/lib/filterx/filterx-metrics.c index c7bf1d27c4..7622793e2b 100644 --- a/lib/filterx/filterx-metrics.c +++ b/lib/filterx/filterx-metrics.c @@ -179,6 +179,28 @@ filterx_metrics_get_stats_counter(FilterXMetrics *self, StatsCounterItem **count return success; } +gboolean +filterx_metrics_init(FilterXMetrics *self, GlobalConfig *cfg) +{ + if (!filterx_expr_init(self->key.expr, cfg)) + return FALSE; + + if (!filterx_metrics_labels_init(self->labels, cfg)) + { + filterx_expr_deinit(self->key.expr, cfg); + return FALSE; + } + + return TRUE; +} + +void +filterx_metrics_deinit(FilterXMetrics *self, GlobalConfig *cfg) +{ + filterx_expr_deinit(self->key.expr, cfg); + filterx_metrics_labels_deinit(self->labels, cfg); +} + void filterx_metrics_free(FilterXMetrics *self) { diff --git a/lib/filterx/filterx-metrics.h b/lib/filterx/filterx-metrics.h index 567885d776..d850d0f22a 100644 --- a/lib/filterx/filterx-metrics.h +++ b/lib/filterx/filterx-metrics.h @@ -34,6 +34,8 @@ gboolean filterx_metrics_is_enabled(FilterXMetrics *self); gboolean filterx_metrics_get_stats_counter(FilterXMetrics *self, StatsCounterItem **counter); FilterXMetrics *filterx_metrics_new(gint level, FilterXExpr *key, FilterXExpr *labels); +gboolean filterx_metrics_init(FilterXMetrics *self, GlobalConfig *cfg); +void filterx_metrics_deinit(FilterXMetrics *self, GlobalConfig *cfg); void filterx_metrics_free(FilterXMetrics *self); #endif diff --git a/lib/filterx/func-flatten.c b/lib/filterx/func-flatten.c index bcda2ec8f7..4b8b79511f 100644 --- a/lib/filterx/func-flatten.c +++ b/lib/filterx/func-flatten.c @@ -208,6 +208,26 @@ _eval(FilterXExpr *s) return result ? filterx_boolean_new(TRUE) : NULL; } +static gboolean +_init(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXFunctionFlatten *self = (FilterXFunctionFlatten *) s; + + if (!filterx_expr_init(self->dict_expr, cfg)) + return FALSE; + + return filterx_function_init_method(&self->super, cfg); +} + +static void +_deinit(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXFunctionFlatten *self = (FilterXFunctionFlatten *) s; + + filterx_expr_deinit(self->dict_expr, cfg); + filterx_function_deinit_method(&self->super, cfg); +} + static void _free(FilterXExpr *s) { @@ -262,6 +282,8 @@ filterx_function_flatten_new(FilterXFunctionArgs *args, GError **error) FilterXFunctionFlatten *self = g_new0(FilterXFunctionFlatten, 1); filterx_function_init_instance(&self->super, "flatten"); self->super.super.eval = _eval; + self->super.super.init = _init; + self->super.super.deinit = _deinit; self->super.super.free_fn = _free; if (!_extract_args(self, args, error)) diff --git a/lib/filterx/func-istype.c b/lib/filterx/func-istype.c index fce1fc0d9f..898dd4d118 100644 --- a/lib/filterx/func-istype.c +++ b/lib/filterx/func-istype.c @@ -59,6 +59,25 @@ _eval(FilterXExpr *s) return filterx_boolean_new(result); } +static gboolean +_init(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXFunctionIsType *self = (FilterXFunctionIsType *) s; + + if (!filterx_expr_init(self->object_expr, cfg)) + return FALSE; + + return filterx_function_init_method(&self->super, cfg); +} + +static void +_deinit(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXFunctionIsType *self = (FilterXFunctionIsType *) s; + filterx_expr_deinit(self->object_expr, cfg); + filterx_function_deinit_method(&self->super, cfg); +} + static void _free(FilterXExpr *s) { @@ -130,6 +149,8 @@ filterx_function_istype_new(FilterXFunctionArgs *args, GError **error) FilterXFunctionIsType *self = g_new0(FilterXFunctionIsType, 1); filterx_function_init_instance(&self->super, "istype"); self->super.super.eval = _eval; + self->super.super.init = _init; + self->super.super.deinit = _deinit; self->super.super.free_fn = _free; if (!_extract_args(self, args, error) || diff --git a/lib/filterx/func-str.c b/lib/filterx/func-str.c index 217473a76d..7d2b55d307 100644 --- a/lib/filterx/func-str.c +++ b/lib/filterx/func-str.c @@ -217,6 +217,33 @@ _expr_affix_init_needle(FilterXExprAffix *self) return TRUE; } +static gboolean +_expr_affix_init(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXExprAffix *self = (FilterXExprAffix *) s; + + if (!filterx_expr_init(self->haystack, cfg)) + return FALSE; + + if (!filterx_expr_init(self->needle.expr, cfg)) + { + filterx_expr_deinit(self->haystack, cfg); + return FALSE; + } + + return filterx_function_init_method(&self->super, cfg); +} + +static void +_expr_affix_deinit(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXExprAffix *self = (FilterXExprAffix *) s; + + filterx_expr_deinit(self->haystack, cfg); + filterx_expr_deinit(self->needle.expr, cfg); + filterx_function_deinit_method(&self->super, cfg); +} + static void _expr_affix_free(FilterXExpr *s) { @@ -376,6 +403,8 @@ _function_affix_new(FilterXFunctionArgs *args, filterx_function_init_instance(&self->super, affix_name); self->super.super.eval = _expr_affix_eval; + self->super.super.init = _expr_affix_init; + self->super.super.deinit = _expr_affix_deinit; self->super.super.free_fn = _expr_affix_free; self->needle.cached_strings = g_ptr_array_new_with_free_func((GDestroyNotify) _string_with_cache_free); diff --git a/lib/filterx/func-unset-empties.c b/lib/filterx/func-unset-empties.c index 0ad388e3db..9ac534d60f 100644 --- a/lib/filterx/func-unset-empties.c +++ b/lib/filterx/func-unset-empties.c @@ -248,6 +248,26 @@ _eval(FilterXExpr *s) return success ? filterx_boolean_new(TRUE) : NULL; } +static gboolean +_init(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXFunctionUnsetEmpties *self = (FilterXFunctionUnsetEmpties *) s; + + if (!filterx_expr_init_method(self->object_expr, cfg)) + return FALSE; + + return filterx_function_init_method(&self->super, cfg); +} + +static void +_deinit(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXFunctionUnsetEmpties *self = (FilterXFunctionUnsetEmpties *) s; + + filterx_expr_deinit(self->object_expr, cfg); + filterx_function_deinit_method(&self->super, cfg); +} + static void _free(FilterXExpr *s) { @@ -486,6 +506,8 @@ filterx_function_unset_empties_new(FilterXFunctionArgs *args, GError **error) FilterXFunctionUnsetEmpties *self = g_new0(FilterXFunctionUnsetEmpties, 1); filterx_function_init_instance(&self->super, "unset_empties"); self->super.super.eval = _eval; + self->super.super.init = _init; + self->super.super.deinit = _deinit; self->super.super.free_fn = _free; reset_flags(&self->flags, ALL_FLAG_SET(FilterXFunctionUnsetEmptiesFlags)); diff --git a/modules/cef/event-format-parser.c b/modules/cef/event-format-parser.c index 3d19c59003..1ecbb7f52a 100644 --- a/modules/cef/event-format-parser.c +++ b/modules/cef/event-format-parser.c @@ -279,6 +279,25 @@ _generate(FilterXExprGenerator *s, FilterXObject *fillable) return ok; } +static gboolean +_init(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXFunctionEventFormatParser *self = (FilterXFunctionEventFormatParser *) s; + + if (!filterx_expr_init(self->msg, cfg)) + return FALSE; + + return filterx_generator_init_method(s, cfg); +} + +static void +_deinit(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXFunctionEventFormatParser *self = (FilterXFunctionEventFormatParser *) s; + filterx_expr_deinit(self->msg, cfg); + filterx_generator_deinit_method(s, cfg); +} + static void _free(FilterXExpr *s) { @@ -383,6 +402,8 @@ filterx_function_parser_init_instance(FilterXFunctionEventFormatParser *self, co filterx_generator_function_init_instance(&self->super, fn_name); self->super.super.generate = _generate; self->super.super.create_container = filterx_generator_create_dict_container; + self->super.super.super.init = _init; + self->super.super.super.deinit = _deinit; self->super.super.super.free_fn = _free; _set_config(self, cfg); diff --git a/modules/csvparser/filterx-func-format-csv.c b/modules/csvparser/filterx-func-format-csv.c index ac4ecd8481..6f47b09980 100644 --- a/modules/csvparser/filterx-func-format-csv.c +++ b/modules/csvparser/filterx-func-format-csv.c @@ -164,6 +164,33 @@ _eval(FilterXExpr *s) return success ? filterx_string_new(formatted->str, formatted->len) : NULL; } +static gboolean +_init(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXFunctionFormatCSV *self = (FilterXFunctionFormatCSV *) s; + + if (!filterx_expr_init(self->input, cfg)) + return FALSE; + + if (!filterx_expr_init(self->columns, cfg)) + { + filterx_expr_deinit(self->input, cfg); + return FALSE; + } + + return filterx_function_init_method(&self->super, cfg); +} + +static void +_deinit(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXFunctionFormatCSV *self = (FilterXFunctionFormatCSV *) s; + + filterx_expr_deinit(self->input, cfg); + filterx_expr_deinit(self->columns, cfg); + filterx_function_deinit_method(&self->super, cfg); +} + static void _free(FilterXExpr *s) { @@ -271,6 +298,8 @@ filterx_function_format_csv_new(FilterXFunctionArgs *args, GError **error) filterx_function_init_instance(&self->super, "format_csv"); self->super.super.eval = _eval; + self->super.super.init = _init; + self->super.super.deinit = _deinit; self->super.super.free_fn = _free; self->delimiter = ','; self->default_value = filterx_string_new("", -1); diff --git a/modules/csvparser/filterx-func-parse-csv.c b/modules/csvparser/filterx-func-parse-csv.c index 95049124f0..c0bd0a28ce 100644 --- a/modules/csvparser/filterx-func-parse-csv.c +++ b/modules/csvparser/filterx-func-parse-csv.c @@ -282,6 +282,40 @@ _generate(FilterXExprGenerator *s, FilterXObject *fillable) return ok; } +static gboolean +_init(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXFunctionParseCSV *self = (FilterXFunctionParseCSV *) s; + + if (!filterx_expr_init(self->msg, cfg)) + return FALSE; + + if (!filterx_expr_init(self->columns.expr, cfg)) + { + filterx_expr_deinit(self->msg, cfg); + return FALSE; + } + + if (!filterx_expr_init(self->string_delimiters, cfg)) + { + filterx_expr_deinit(self->msg, cfg); + filterx_expr_deinit(self->columns.expr, cfg); + return FALSE; + } + + return filterx_generator_function_init_method(&self->super, cfg); +} + +static void +_deinit(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXFunctionParseCSV *self = (FilterXFunctionParseCSV *) s; + filterx_expr_deinit(self->msg, cfg); + filterx_expr_deinit(self->columns.expr, cfg); + filterx_expr_deinit(self->string_delimiters, cfg); + filterx_generator_function_deinit_method(&self->super, cfg); +} + static void _free(FilterXExpr *s) { @@ -505,6 +539,8 @@ filterx_function_parse_csv_new(FilterXFunctionArgs *args, GError **error) filterx_generator_function_init_instance(&self->super, "parse_csv"); self->super.super.generate = _generate; self->super.super.create_container = _create_container; + self->super.super.super.init = _init; + self->super.super.super.deinit = _deinit; self->super.super.super.free_fn = _free; csv_scanner_options_set_delimiters(&self->options, ","); csv_scanner_options_set_quote_pairs(&self->options, "\"\"''"); diff --git a/modules/kvformat/filterx-func-format-kv.c b/modules/kvformat/filterx-func-format-kv.c index 478d2ef1ad..3e340afdac 100644 --- a/modules/kvformat/filterx-func-format-kv.c +++ b/modules/kvformat/filterx-func-format-kv.c @@ -116,6 +116,26 @@ _eval(FilterXExpr *s) return success ? filterx_string_new(formatted->str, formatted->len) : NULL; } +static gboolean +_init(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXFunctionFormatKV *self = (FilterXFunctionFormatKV *) s; + + if (!filterx_expr_init(self->kvs, cfg)) + return FALSE; + + return filterx_function_init_method(&self->super, cfg); +} + +static void +_deinit(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXFunctionFormatKV *self = (FilterXFunctionFormatKV *) s; + + filterx_expr_deinit(self->kvs, cfg); + filterx_function_deinit_method(&self->super, cfg); +} + static void _free(FilterXExpr *s) { @@ -218,6 +238,8 @@ filterx_function_format_kv_new(FilterXFunctionArgs *args, GError **error) filterx_function_init_instance(&self->super, "format_kv"); self->super.super.eval = _eval; + self->super.super.init = _init; + self->super.super.deinit = _deinit; self->super.super.free_fn = _free; self->value_separator = '='; self->pair_separator = g_strdup(", "); diff --git a/modules/kvformat/filterx-func-parse-kv.c b/modules/kvformat/filterx-func-parse-kv.c index 6b040e04b1..5e88874085 100644 --- a/modules/kvformat/filterx-func-parse-kv.c +++ b/modules/kvformat/filterx-func-parse-kv.c @@ -145,6 +145,25 @@ _generate(FilterXExprGenerator *s, FilterXObject *fillable) return result; } +static gboolean +_init(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXFunctionParseKV *self = (FilterXFunctionParseKV *) s; + + if (!filterx_expr_init(self->msg, cfg)) + return FALSE; + + return filterx_generator_function_init_method(&self->super, cfg); +} + +static void +_deinit(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXFunctionParseKV *self = (FilterXFunctionParseKV *) s; + filterx_expr_deinit(self->msg, cfg); + filterx_generator_function_deinit_method(&self->super, cfg); +} + static void _free(FilterXExpr *s) { @@ -255,6 +274,8 @@ filterx_function_parse_kv_new(FilterXFunctionArgs *args, GError **error) filterx_generator_function_init_instance(&self->super, "parse_kv"); self->super.super.generate = _generate; self->super.super.create_container = filterx_generator_create_dict_container; + self->super.super.super.init = _init; + self->super.super.super.deinit = _deinit; self->super.super.super.free_fn = _free; self->value_separator = '='; self->pair_separator = g_strdup(", "); diff --git a/modules/metrics-probe/filterx/func-update-metric.c b/modules/metrics-probe/filterx/func-update-metric.c index 4e9dea8467..bcdc5e0e83 100644 --- a/modules/metrics-probe/filterx/func-update-metric.c +++ b/modules/metrics-probe/filterx/func-update-metric.c @@ -94,6 +94,32 @@ _eval(FilterXExpr *s) return filterx_boolean_new(TRUE); } +static gboolean +_init(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXFunctionUpdateMetric *self = (FilterXFunctionUpdateMetric *) s; + + if (!filterx_expr_init(self->increment.expr, cfg)) + return FALSE; + + if (!filterx_metrics_init(self->metrics, cfg)) + { + filterx_expr_deinit(self->increment.expr, cfg); + return FALSE; + } + + return filterx_function_init_method(&self->super, cfg); +} + +static void +_deinit(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXFunctionUpdateMetric *self = (FilterXFunctionUpdateMetric *) s; + filterx_expr_deinit(self->increment.expr, cfg); + filterx_metrics_deinit(self->metrics, cfg); + filterx_function_deinit_method(&self->super, cfg); +} + static void _free(FilterXExpr *s) { @@ -201,6 +227,8 @@ filterx_function_update_metric_new(FilterXFunctionArgs *args, GError **error) filterx_function_init_instance(&self->super, "update_metric"); self->super.super.eval = _eval; + self->super.super.init = _init; + self->super.super.deinit = _deinit; self->super.super.free_fn = _free; if (!_extract_args(self, args, error) || diff --git a/modules/xml/filterx-parse-xml.c b/modules/xml/filterx-parse-xml.c index 56db99cca3..ef6376d37e 100644 --- a/modules/xml/filterx-parse-xml.c +++ b/modules/xml/filterx-parse-xml.c @@ -710,6 +710,26 @@ _extract_args(FilterXGeneratorFunctionParseXml *self, FilterXFunctionArgs *args, return TRUE; } +static gboolean +_init(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXGeneratorFunctionParseXml *self = (FilterXGeneratorFunctionParseXml *) s; + + if (!filterx_expr_init(self->xml_expr, cfg)) + return FALSE; + + return filterx_generator_function_init_method(&self->super, cfg); +} + +static void +_deinit(FilterXExpr *s, GlobalConfig *cfg) +{ + FilterXGeneratorFunctionParseXml *self = (FilterXGeneratorFunctionParseXml *) s; + + filterx_expr_deinit(self->xml_expr, cfg); + filterx_generator_function_deinit_method(&self->super, cfg); +} + static void _free(FilterXExpr *s) { @@ -727,6 +747,8 @@ filterx_generator_function_parse_xml_new(FilterXFunctionArgs *args, GError **err filterx_generator_function_init_instance(&self->super, "parse_xml"); self->super.super.generate = _generate; self->super.super.create_container = filterx_generator_create_dict_container; + self->super.super.super.init = _init; + self->super.super.super.deinit = _deinit; self->super.super.super.free_fn = _free; self->create_state = _state_new;