Skip to content

Commit 6518973

Browse files
authored
remove jit stack
1 parent 0d81b63 commit 6518973

File tree

4 files changed

+11
-27
lines changed

4 files changed

+11
-27
lines changed

src/operators/verify_cc.cc

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ namespace operators {
3636
VerifyCC::~VerifyCC() {
3737
#if WITH_PCRE2
3838
pcre2_code_free(m_pc);
39-
pcre2_match_context_free(m_pmc);
40-
pcre2_jit_stack_free(m_pcjs);
4139
#else
4240
if (m_pc != NULL) {
4341
pcre_free(m_pc);
@@ -107,11 +105,7 @@ bool VerifyCC::init(const std::string &param2, std::string *error) {
107105
if (m_pc == NULL) {
108106
return false;
109107
}
110-
111108
m_pcje = pcre2_jit_compile(m_pc, PCRE2_JIT_COMPLETE);
112-
m_pmc = pcre2_match_context_create(NULL);
113-
m_pcjs = pcre2_jit_stack_create(32*1024, 512*1024, NULL);
114-
pcre2_jit_stack_assign(m_pmc, NULL, m_pcjs);
115109
#else
116110
const char *errptr = NULL;
117111
int erroffset = 0;
@@ -153,9 +147,9 @@ bool VerifyCC::evaluate(Transaction *t, RuleWithActions *rule,
153147
for (offset = 0; offset < target_length; offset++) {
154148

155149
if (m_pcje == 0) {
156-
ret = pcre2_jit_match(m_pc, pcre2_i, target_length, offset, 0, match_data, m_pmc);
150+
ret = pcre2_jit_match(m_pc, pcre2_i, target_length, offset, 0, match_data, NULL);
157151
} else {
158-
ret = pcre2_match(m_pc, pcre2_i, target_length, offset, 0, match_data, m_pmc);
152+
ret = pcre2_match(m_pc, pcre2_i, target_length, offset, 0, match_data, NULL);
159153
}
160154

161155
/* If there was no match, then we are done. */

src/operators/verify_cc.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ class VerifyCC : public Operator {
5353
private:
5454
#if WITH_PCRE2
5555
pcre2_code *m_pc;
56-
pcre2_match_context *m_pmc;
5756
int m_pcje;
58-
pcre2_jit_stack *m_pcjs;
5957
#else
6058
pcre *m_pc;
6159
pcre_extra *m_pce;

src/utils/regex.cc

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,7 @@ Regex::Regex(const std::string& pattern_, bool ignoreCase)
7373
PCRE2_SIZE erroroffset = 0;
7474
m_pc = pcre2_compile(pcre2_pattern, PCRE2_ZERO_TERMINATED,
7575
pcre2_options, &errornumber, &erroroffset, NULL);
76-
7776
m_pcje = pcre2_jit_compile(m_pc, PCRE2_JIT_COMPLETE);
78-
m_pmc = pcre2_match_context_create(NULL);
79-
m_pcjs = pcre2_jit_stack_create(32*1024, 512*1024, NULL);
80-
pcre2_jit_stack_assign(m_pmc, NULL, m_pcjs);
8177
#else
8278
const char *errptr = NULL;
8379
int erroffset;
@@ -97,8 +93,6 @@ Regex::Regex(const std::string& pattern_, bool ignoreCase)
9793
Regex::~Regex() {
9894
#if WITH_PCRE2
9995
pcre2_code_free(m_pc);
100-
pcre2_match_context_free(m_pmc);
101-
pcre2_jit_stack_free(m_pcjs);
10296
#else
10397
if (m_pc != NULL) {
10498
pcre_free(m_pc);
@@ -127,10 +121,10 @@ std::list<SMatch> Regex::searchAll(const std::string& s) const {
127121
do {
128122
if (m_pcje == 0) {
129123
rc = pcre2_jit_match(m_pc, pcre2_s, s.length(),
130-
offset, 0, match_data, m_pmc);
124+
offset, 0, match_data, NULL);
131125
} else {
132126
rc = pcre2_match(m_pc, pcre2_s, s.length(),
133-
offset, 0, match_data, m_pmc);
127+
offset, 0, match_data, NULL);
134128
}
135129
PCRE2_SIZE *ovector = pcre2_get_ovector_pointer(match_data);
136130
#else
@@ -173,9 +167,9 @@ bool Regex::searchOneMatch(const std::string& s, std::vector<SMatchCapture>& cap
173167
pcre2_match_data *match_data = pcre2_match_data_create_from_pattern(m_pc, NULL);
174168
int rc;
175169
if (m_pcje == 0) {
176-
rc = pcre2_jit_match(m_pc, pcre2_s, s.length(), 0, 0, match_data, m_pmc);
170+
rc = pcre2_jit_match(m_pc, pcre2_s, s.length(), 0, 0, match_data, NULL);
177171
} else {
178-
rc = pcre2_match(m_pc, pcre2_s, s.length(), 0, 0, match_data, m_pmc);
172+
rc = pcre2_match(m_pc, pcre2_s, s.length(), 0, 0, match_data, NULL);
179173
}
180174
PCRE2_SIZE *ovector = pcre2_get_ovector_pointer(match_data);
181175
#else
@@ -215,7 +209,7 @@ bool Regex::searchGlobal(const std::string& s, std::vector<SMatchCapture>& captu
215209
pcre2_options = PCRE2_NOTEMPTY_ATSTART | PCRE2_ANCHORED;
216210
}
217211
int rc = pcre2_match(m_pc, pcre2_s, s.length(),
218-
startOffset, pcre2_options, match_data, m_pmc);
212+
startOffset, pcre2_options, match_data, NULL);
219213
PCRE2_SIZE *ovector = pcre2_get_ovector_pointer(match_data);
220214

221215
#else
@@ -290,10 +284,10 @@ int Regex::search(const std::string& s, SMatch *match) const {
290284
int ret;
291285
if (m_pcje == 0) {
292286
ret = pcre2_match(m_pc, pcre2_s, s.length(),
293-
0, 0, match_data, m_pmc) > 0;
287+
0, 0, match_data, NULL) > 0;
294288
} else {
295289
ret = pcre2_match(m_pc, pcre2_s, s.length(),
296-
0, 0, match_data, m_pmc) > 0;
290+
0, 0, match_data, NULL) > 0;
297291
}
298292
if (ret > 0) { // match
299293
PCRE2_SIZE *ovector = pcre2_get_ovector_pointer(match_data);
@@ -321,9 +315,9 @@ int Regex::search(const std::string& s) const {
321315
pcre2_match_data *match_data = pcre2_match_data_create_from_pattern(m_pc, NULL);
322316
int rc;
323317
if (m_pcje == 0) {
324-
rc = pcre2_jit_match(m_pc, pcre2_s, s.length(), 0, 0, match_data, m_pmc);
318+
rc = pcre2_jit_match(m_pc, pcre2_s, s.length(), 0, 0, match_data, NULL);
325319
} else {
326-
rc = pcre2_match(m_pc, pcre2_s, s.length(), 0, 0, match_data, m_pmc);
320+
rc = pcre2_match(m_pc, pcre2_s, s.length(), 0, 0, match_data, NULL);
327321
}
328322
pcre2_match_data_free(match_data);
329323
if (rc > 0) {

src/utils/regex.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@ class Regex {
8585
private:
8686
#if WITH_PCRE2
8787
pcre2_code *m_pc;
88-
pcre2_match_context *m_pmc;
8988
int m_pcje;
90-
pcre2_jit_stack *m_pcjs;
9189
#else
9290
pcre *m_pc = NULL;
9391
pcre_extra *m_pce = NULL;

0 commit comments

Comments
 (0)