| 924 | |
| 925 | |
| 926 | pcre2_code * wrap_pcre_compile(char * pattern, int flags) |
| 927 | { |
| 928 | pcre2_code * ret ; |
| 929 | PCRE2_ERR error; |
| 930 | PCRE2_SIZE erroffset; |
| 931 | int pcre_flags = 0; |
| 932 | |
| 933 | #ifndef PCRE2_LIB |
| 934 | void *(*old_malloc)(size_t) = pcre_malloc; |
| 935 | void (*old_free)(void *) = pcre_free; |
| 936 | |
| 937 | pcre_malloc = wrap_shm_malloc; |
| 938 | pcre_free = wrap_shm_free; |
| 939 | #endif |
| 940 | |
| 941 | if (flags & DP_CASE_INSENSITIVE) |
| 942 | pcre_flags |= PCRE2_CASELESS; |
| 943 | |
| 944 | ret = pcre2_compile( |
| 945 | (PCRE2_SPTR)pattern, /* the pattern */ |
| 946 | PCRE2_ZERO_TERMINATED, |
| 947 | pcre_flags, /* default options */ |
| 948 | &error, /* for error message */ |
| 949 | &erroffset, /* for error offset */ |
| 950 | dp_ccontext); /* compile context, to allocate memory in shm */ |
| 951 | |
| 952 | #ifndef PCRE2_LIB |
| 953 | pcre_malloc = old_malloc; |
| 954 | pcre_free = old_free; |
| 955 | #endif |
| 956 | |
| 957 | return ret; |
| 958 | } |
| 959 | |
| 960 | void wrap_pcre_free( pcre2_code* re) |
| 961 | { |