MEDIUM: regex: modify regex_comp() to atomically allocate/free the my_regex struct

Now we atomically allocate the my_regex struct within function
regex_comp() and compile the regex or free both in case of failure. The
pointer to the allocated my_regex struct is returned directly. The
my_regex* argument to regex_comp() is removed.

Function regex_free() was modified so that it systematically frees the
my_regex entry. The function does nothing when called with a NULL as
argument (like free()). It will avoid existing risk of not properly
freeing the initialized area.

Other structures are also updated in order to be compatible (the ones
related to Lua and action rules).
diff --git a/include/common/regex.h b/include/common/regex.h
index c3b921b..0814f8f 100644
--- a/include/common/regex.h
+++ b/include/common/regex.h
@@ -88,7 +88,7 @@
  *
  * The function return 1 is succes case, else return 0 and err is filled.
  */
-int regex_comp(const char *str, struct my_regex *regex, int cs, int cap, char **err);
+struct my_regex *regex_comp(const char *str, int cs, int cap, char **err);
 int exp_replace(char *dst, unsigned int dst_size, char *src, const char *str, const regmatch_t *matches);
 const char *check_replace_string(const char *str);
 const char *chain_regex(struct hdr_exp **head, struct my_regex *preg,
@@ -161,6 +161,8 @@
                       size_t nmatch, regmatch_t pmatch[], int flags);
 
 static inline void regex_free(struct my_regex *preg) {
+	if (!preg)
+		return;
 #if defined(USE_PCRE) || defined(USE_PCRE_JIT)
 	pcre_free(preg->reg);
 /* PCRE < 8.20 requires pcre_free() while >= 8.20 requires pcre_study_free(),
@@ -176,6 +178,7 @@
 #else
 	regfree(&preg->regex);
 #endif
+	free(preg);
 }
 
 #endif /* _COMMON_REGEX_H */