mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
-Added regex cache
-Made module thread-safe
This commit is contained in:
parent
c57c0e9cd5
commit
e3a70c1f04
2 changed files with 115 additions and 17 deletions
|
@ -37,6 +37,8 @@
|
|||
#include "pcre.h"
|
||||
|
||||
extern void php_info_pcre(ZEND_MODULE_INFO_FUNC_ARGS);
|
||||
extern int php_minit_pcre(INIT_FUNC_ARGS);
|
||||
extern int php_mshutdown_pcre(SHUTDOWN_FUNC_ARGS);
|
||||
extern int php_rinit_pcre(INIT_FUNC_ARGS);
|
||||
|
||||
PHP_FUNCTION(pcre_match);
|
||||
|
@ -45,6 +47,32 @@ PHP_FUNCTION(pcre_replace);
|
|||
extern zend_module_entry pcre_module_entry;
|
||||
#define pcre_module_ptr &pcre_module_entry
|
||||
|
||||
typedef struct {
|
||||
pcre *re;
|
||||
pcre_extra *extra;
|
||||
} pcre_cache_entry;
|
||||
|
||||
typedef struct {
|
||||
HashTable pcre_cache;
|
||||
} php_pcre_globals;
|
||||
|
||||
#ifdef ZTS
|
||||
# define PCRE_LS_D php_pcre_globals *pcre_globals
|
||||
# define PCRE_LS_DC , PCRE_LS_D
|
||||
# define PCRE_LS_C pcre_globals
|
||||
# define PCRE_LS_CC , PCRE_LS_C
|
||||
# define PCRE_G(v) (pcre_globals->v)
|
||||
# define PCRE_LS_FETCH() php_pcre_globals *pcre_globals = ts_resource(pcre_globals_id);
|
||||
#else
|
||||
# define PCRE_LS_D
|
||||
# define PCRE_LS_DC
|
||||
# define PCRE_LS_C
|
||||
# define PCRE_LS_CC
|
||||
# define PCRE_G(v) (pcre_globals.v)
|
||||
# define PCRE_LS_FETCH()
|
||||
extern ZEND_API php_pcre_globals pcre_globals;
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#define pcre_module_ptr NULL
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue