X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Futils_vl_lookup.c;h=8a2e5671110f196e9ba72166303d9fbd436826b9;hb=444438552db9fa889fb0b15e8c68ed1804312c1f;hp=d3eeab3c06fa9b784993d9b3a983d3bcf215ed83;hpb=f14bb45d570e0b34bdd3a2a0cadfe414c3dfda40;p=collectd.git diff --git a/src/utils_vl_lookup.c b/src/utils_vl_lookup.c index d3eeab3c..8a2e5671 100644 --- a/src/utils_vl_lookup.c +++ b/src/utils_vl_lookup.c @@ -157,7 +157,7 @@ static int lu_copy_ident_to_match_part (part_match_t *match_part, /* {{{ */ assert (sizeof (match_part->str) > len); /* strip trailing slash */ match_part->str[len - 2] = 0; - + status = regcomp (&match_part->regex, match_part->str, /* flags = */ REG_EXTENDED); if (status != 0) @@ -169,7 +169,7 @@ static int lu_copy_ident_to_match_part (part_match_t *match_part, /* {{{ */ return (EINVAL); } match_part->is_regex = 1; - + return (0); } /* }}} int lu_copy_ident_to_match_part */ @@ -336,7 +336,7 @@ static int lu_handle_user_class_list (lookup_t *obj, /* {{{ */ { user_class_list_t *ptr; int retval = 0; - + for (ptr = user_class_list; ptr != NULL; ptr = ptr->next) { int status; @@ -401,7 +401,7 @@ static by_type_entry_t *lu_search_by_type (lookup_t *obj, /* {{{ */ sfree (type_copy); return (NULL); } - + return (by_type); } /* }}} by_type_entry_t *lu_search_by_type */ @@ -495,6 +495,21 @@ static void lu_destroy_user_class_list (lookup_t *obj, /* {{{ */ obj->cb_free_class (user_class_list->entry.user_class); user_class_list->entry.user_class = NULL; +#define CLEAR_FIELD(field) do { \ + if (user_class_list->entry.match.field.is_regex) { \ + regfree (&user_class_list->entry.match.field.regex); \ + user_class_list->entry.match.field.is_regex = 0; \ + } \ +} while (0) + + CLEAR_FIELD (host); + CLEAR_FIELD (plugin); + CLEAR_FIELD (plugin_instance); + CLEAR_FIELD (type); + CLEAR_FIELD (type_instance); + +#undef CLEAR_FIELD + lu_destroy_user_obj (obj, user_class_list->entry.user_obj_list); user_class_list->entry.user_obj_list = NULL; pthread_mutex_destroy (&user_class_list->entry.lock); @@ -507,7 +522,7 @@ static void lu_destroy_user_class_list (lookup_t *obj, /* {{{ */ static void lu_destroy_by_type (lookup_t *obj, /* {{{ */ by_type_entry_t *by_type) { - + while (42) { char *plugin = NULL; @@ -651,6 +666,6 @@ int lookup_search (lookup_t *obj, /* {{{ */ return (status); retval += status; } - + return (retval); } /* }}} lookup_search */