--- parser3/src/main/pa_globals.C 2020/12/15 17:10:36 1.211 +++ parser3/src/main/pa_globals.C 2026/04/25 13:38:46 1.219 @@ -1,8 +1,8 @@ /** @file Parser: globals. - Copyright (c) 2001-2020 Art. Lebedev Studio (http://www.artlebedev.com) - Author: Alexandr Petrosian (http://paf.design.ru) + Copyright (c) 2001-2026 Art. Lebedev Studio (https://www.artlebedev.com) + Authors: Konstantin Morshnev , Alexandr Petrosian */ #include "pa_config_includes.h" @@ -19,7 +19,6 @@ extern "C" { #include "pa_globals.h" #include "pa_socks.h" #include "pa_sapi.h" -#include "pa_threads.h" #include "pa_xml_io.h" #include "pa_common.h" #include "pa_symbols.h" @@ -27,9 +26,9 @@ extern "C" { #include "pa_cache_managers.h" #include "ltdl.h" -#include "pcre.h" +#include "pa_vregex.h" -volatile const char * IDENT_PA_GLOBALS_C="$Id: pa_globals.C,v 1.211 2020/12/15 17:10:36 moko Exp $" IDENT_PA_GLOBALS_H IDENT_PA_SAPI_H; +volatile const char * IDENT_PA_GLOBALS_C="$Id: pa_globals.C,v 1.219 2026/04/25 13:38:46 moko Exp $" IDENT_PA_GLOBALS_H IDENT_PA_SAPI_H; // defines @@ -178,10 +177,30 @@ static void pa_gc_free_maybeignore(void* #endif // XML +#ifdef HAVE_PCRE2 +pcre2_general_context* VRegex::fgen_ctxt; + +static void* pa_pcre_malloc(size_t size, void *){ + return pa_malloc(size); +} + +static void pa_pcre_free(void *ptr, void *){ + pa_free(ptr); +} +#endif + + void pa_CORD_oom_fn(void) { pa_fail_alloc("expand string", 0); } +#ifndef PA_DEBUG_DISABLE_GC +extern "C" void *pa_fail_alloc(const char*); +extern "C" void pa_GC_abort_func(const char *msg) { + pa_fail_alloc(msg); +} +#endif + /** @todo gc: libltdl: substitute lt_dlmalloc & co */ @@ -208,8 +227,12 @@ static void gc_substitute_memory_managem #endif // pcre +#ifdef HAVE_PCRE2 + VRegex::fgen_ctxt=pcre2_general_context_create(pa_pcre_malloc, pa_pcre_free, NULL); +#else pcre_malloc=pa_malloc; pcre_free=pa_free; +#endif // cord CORD_oom_fn=pa_CORD_oom_fn; @@ -226,6 +249,8 @@ void pa_globals_init() { GC_disable(); // as we log allocation errors, we don't need default gc warnings (without timestamp and URI) GC_set_warn_proc(GC_ignore_warn_proc); + // to prevent "mmap(PROT_NONE) failed + Aborted" under Linux + GC_set_abort_func(pa_GC_abort_func); #endif // init socks @@ -286,6 +311,9 @@ void pa_globals_init() { pa_xml_io_init(); #endif + + // init *_class variables + methoded_array(); } static bool is_dlinited=false;