6
#include "ngx_http_lua_pcrefix.h"
10
static ngx_pool_t *ngx_http_lua_pcre_pool;
12
static void *(*old_pcre_malloc)(size_t);
13
static void (*old_pcre_free)(void *ptr);
16
/* XXX: work-around to nginx regex subsystem, must init a memory pool
17
* to use PCRE functions. As PCRE still has memory-leaking problems,
18
* and nginx overwrote pcre_malloc/free hooks with its own static
19
* functions, so nobody else can reuse nginx regex subsystem... */
21
ngx_http_lua_pcre_malloc(size_t size)
23
if (ngx_http_lua_pcre_pool) {
24
return ngx_palloc(ngx_http_lua_pcre_pool, size);
32
ngx_http_lua_pcre_free(void *ptr)
34
if (ngx_http_lua_pcre_pool) {
35
ngx_pfree(ngx_http_lua_pcre_pool, ptr);
41
ngx_http_lua_pcre_malloc_init(ngx_pool_t *pool)
43
ngx_http_lua_pcre_pool = pool;
45
old_pcre_malloc = pcre_malloc;
46
old_pcre_free = pcre_free;
48
pcre_malloc = ngx_http_lua_pcre_malloc;
49
pcre_free = ngx_http_lua_pcre_free;
54
ngx_http_lua_pcre_malloc_done()
56
ngx_http_lua_pcre_pool = NULL;
58
pcre_malloc = old_pcre_malloc;
59
pcre_free = old_pcre_free;
64
/* vim:set ft=c ts=4 sw=4 et fdm=marker: */