}
void DetectParseFreeRegex(DetectParseRegex *r)
-{
- if (r->regex) {
- pcre2_code_free(r->regex);
- }
- if (r->match) {
- pcre2_match_data_free(r->match);
- }
-}
-
-void DetectParseFreePCRE2(DetectParseRegex2 *r)
{
if (r->regex) {
pcre2_code_free(r->regex);
}
}
-static DetectParseRegex2 *g_detect_pcre2_list = NULL;
-
void DetectParseFreeRegexes(void)
{
DetectParseRegex *r = g_detect_parse_regex_list;
r = next;
}
g_detect_parse_regex_list = NULL;
-
- DetectParseRegex2 *r2 = g_detect_pcre2_list;
- while (r2) {
- DetectParseRegex2 *next = r2->next;
- DetectParseFreePCRE2(r2);
- SCFree(r2);
- r2 = next;
- }
- g_detect_pcre2_list = NULL;
}
/** \brief add regex and/or study to at exit free list
return true;
}
-/** \brief add pcre2 to at exit free list
- */
-static void DetectPCRE2AddToFreeList(DetectParseRegex2 *detect_parse)
-{
- // TODO g_detect_parse_regex_list
- detect_parse->next = g_detect_pcre2_list;
- g_detect_pcre2_list = detect_parse;
-}
-
-DetectParseRegex2 *DetectSetupPCRE2(const char *parse_str, int opts)
+DetectParseRegex *DetectSetupPCRE2(const char *parse_str, int opts)
{
int en;
PCRE2_SIZE eo;
- DetectParseRegex2 *detect_parse = SCCalloc(1, sizeof(DetectParseRegex2));
+ DetectParseRegex *detect_parse = SCCalloc(1, sizeof(DetectParseRegex));
if (detect_parse == NULL) {
return NULL;
}
}
detect_parse->match = pcre2_match_data_create_from_pattern(detect_parse->regex, NULL);
- DetectPCRE2AddToFreeList(detect_parse);
+ detect_parse->next = g_detect_parse_regex_list;
+ g_detect_parse_regex_list = detect_parse;
return detect_parse;
}
SIG_DIREC_DST
};
-typedef struct DetectParseRegex_ {
- pcre2_code *regex;
- pcre2_match_data *match;
- struct DetectParseRegex_ *next;
-} DetectParseRegex;
-
-typedef struct DetectParseRegex2 {
+typedef struct DetectParseRegex {
pcre2_code *regex;
pcre2_match_context *context;
pcre2_match_data *match;
- struct DetectParseRegex2 *next;
-} DetectParseRegex2;
+ struct DetectParseRegex *next;
+} DetectParseRegex;
/* prototypes */
Signature *SigAlloc(void);
/* parse regex setup and free util funcs */
-void DetectParseFreePCRE2(DetectParseRegex2 *r);
-DetectParseRegex2 *DetectSetupPCRE2(const char *parse_str, int opts);
+DetectParseRegex *DetectSetupPCRE2(const char *parse_str, int opts);
bool DetectSetupParseRegexesOpts(const char *parse_str, DetectParseRegex *parse_regex, int opts);
void DetectSetupParseRegexes(const char *parse_str, DetectParseRegex *parse_regex);
void DetectParseRegexAddToFreeList(DetectParseRegex *parse_regex);
static int pcre_match_limit = 0;
static int pcre_match_limit_recursion = 0;
-static DetectParseRegex2 *parse_regex;
-static DetectParseRegex2 *parse_capture_regex;
+static DetectParseRegex *parse_regex;
+static DetectParseRegex *parse_capture_regex;
#ifdef PCRE2_HAVE_JIT
static int pcre2_use_jit = 1;
return;
DetectPcreData *pd = (DetectPcreData *)ptr;
- DetectParseFreePCRE2(&pd->parse_regex);
+ DetectParseFreeRegex(&pd->parse_regex);
SCFree(pd);
return;