X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Futils_match.c;h=e8add2d800f130f0d9273d92065573e4ad503a40;hb=6c97677d92ee28bf35dfe7b2c30b348fe8d2848b;hp=e2f29808afa4ba5331277e658321afa3d04d6dae;hpb=fb0cc621d4357bbe4a9dc36c7f055f46257ce57c;p=collectd.git diff --git a/src/utils_match.c b/src/utils_match.c index e2f29808..e8add2d8 100644 --- a/src/utils_match.c +++ b/src/utils_match.c @@ -34,6 +34,7 @@ #include #define UTILS_MATCH_FLAGS_EXCLUDE_REGEX 0x02 +#define UTILS_MATCH_FLAGS_REGEX 0x04 struct cu_match_s { regex_t regex; @@ -234,6 +235,7 @@ match_create_callback(const char *regex, const char *excluderegex, sfree(obj); return (NULL); } + obj->flags |= UTILS_MATCH_FLAGS_REGEX; if (excluderegex && strcmp(excluderegex, "") != 0) { status = regcomp(&obj->excluderegex, excluderegex, REG_EXTENDED); @@ -301,6 +303,10 @@ void match_destroy(cu_match_t *obj) { if (obj == NULL) return; + if (obj->flags & UTILS_MATCH_FLAGS_REGEX) + regfree(&obj->regex); + if (obj->flags & UTILS_MATCH_FLAGS_EXCLUDE_REGEX) + regfree(&obj->excluderegex); if ((obj->user_data != NULL) && (obj->free != NULL)) (*obj->free)(obj->user_data);