-Added regex cache

-Made module thread-safe
This commit is contained in:
Andrey Hristov 1999-05-21 19:27:44 +00:00
parent c57c0e9cd5
commit e3a70c1f04
2 changed files with 115 additions and 17 deletions

View file

@ -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