summaryrefslogtreecommitdiff
path: root/src/sp_pcre_compat.c
diff options
context:
space:
mode:
authorBen Fuhrmannek2021-08-02 10:42:12 +0200
committerBen Fuhrmannek2021-08-02 10:42:12 +0200
commit4cda0120313dfd5d71236f6faf87416e93f5f89c (patch)
tree0c2c6d15e8ac5287fb3304f96de719547d9e847a /src/sp_pcre_compat.c
parent6c132e6a1d8d339a20282afb5a4af52eb6bce9db (diff)
parente62f226c3ed885808c832040872fc2d73ca46dac (diff)
Merge branch 'master' of https://github.com/jvoisin/snuffleupagus
Diffstat (limited to 'src/sp_pcre_compat.c')
-rw-r--r--src/sp_pcre_compat.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/sp_pcre_compat.c b/src/sp_pcre_compat.c
index 509a8ea..3bd00ca 100644
--- a/src/sp_pcre_compat.c
+++ b/src/sp_pcre_compat.c
@@ -1,5 +1,12 @@
1#include "php_snuffleupagus.h" 1#include "php_snuffleupagus.h"
2 2
3inline void sp_pcre_free(sp_pcre* regexp) {
4#ifdef SP_HAS_PCRE2
5 pcre2_code_free(regexp);
6#endif
7 regexp = NULL;
8}
9
3sp_pcre* sp_pcre_compile(const char* const pattern) { 10sp_pcre* sp_pcre_compile(const char* const pattern) {
4 assert(NULL != pattern); 11 assert(NULL != pattern);
5 12
@@ -34,7 +41,11 @@ bool ZEND_HOT sp_is_regexp_matching_len(const sp_pcre* regexp, const char* str,
34#ifdef SP_HAS_PCRE2 41#ifdef SP_HAS_PCRE2
35 pcre2_match_data* match_data = 42 pcre2_match_data* match_data =
36 pcre2_match_data_create_from_pattern(regexp, NULL); 43 pcre2_match_data_create_from_pattern(regexp, NULL);
44 if (NULL == match_data) {
45 sp_log_err("regexp", "Unable to get memory for a regxp.");
46 }
37 ret = pcre2_match(regexp, (PCRE2_SPTR)str, len, 0, 0, match_data, NULL); 47 ret = pcre2_match(regexp, (PCRE2_SPTR)str, len, 0, 0, match_data, NULL);
48 pcre2_match_data_free(match_data);
38#else 49#else
39 int vec[30]; 50 int vec[30];
40 ret = pcre_exec(regexp, NULL, str, len, 0, 0, vec, sizeof(vec) / sizeof(int)); 51 ret = pcre_exec(regexp, NULL, str, len, 0, 0, vec, sizeof(vec) / sizeof(int));