~ubuntu-branches/ubuntu/quantal/nginx/quantal-updates

« back to all changes in this revision

Viewing changes to debian/modules/nginx-lua/src/ngx_http_lua_pcrefix.c

  • Committer: Package Import Robot
  • Author(s): Kartik Mistry, Kartik Mistry
  • Date: 2011-09-26 10:17:04 UTC
  • mfrom: (4.2.38 sid)
  • Revision ID: package-import@ubuntu.com-20110926101704-x8pxngiujrmkxnn3
Tags: 1.1.4-2
[Kartik Mistry]
* debian/modules:
  + Updated nginx-upload-progress module, Thanks to upstream for fixing issue
    that FTBFS nginx on kFreeBSD-* archs.
  + Updated nginx-lua module to latest upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef DDEBUG
 
2
#define DDEBUG 0
 
3
#endif
 
4
#include "ddebug.h"
 
5
 
 
6
#include "ngx_http_lua_pcrefix.h"
 
7
 
 
8
#if (NGX_PCRE)
 
9
 
 
10
static ngx_pool_t *ngx_http_lua_pcre_pool;
 
11
 
 
12
static void *(*old_pcre_malloc)(size_t);
 
13
static void (*old_pcre_free)(void *ptr);
 
14
 
 
15
 
 
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... */
 
20
static void *
 
21
ngx_http_lua_pcre_malloc(size_t size)
 
22
{
 
23
        if (ngx_http_lua_pcre_pool) {
 
24
                return ngx_palloc(ngx_http_lua_pcre_pool, size);
 
25
        }
 
26
 
 
27
        return NULL;
 
28
}
 
29
 
 
30
 
 
31
static void
 
32
ngx_http_lua_pcre_free(void *ptr)
 
33
{
 
34
        if (ngx_http_lua_pcre_pool) {
 
35
                ngx_pfree(ngx_http_lua_pcre_pool, ptr);
 
36
        }
 
37
}
 
38
 
 
39
 
 
40
void
 
41
ngx_http_lua_pcre_malloc_init(ngx_pool_t *pool)
 
42
{
 
43
        ngx_http_lua_pcre_pool = pool;
 
44
 
 
45
        old_pcre_malloc = pcre_malloc;
 
46
        old_pcre_free = pcre_free;
 
47
 
 
48
    pcre_malloc = ngx_http_lua_pcre_malloc;
 
49
    pcre_free = ngx_http_lua_pcre_free;
 
50
}
 
51
 
 
52
 
 
53
void
 
54
ngx_http_lua_pcre_malloc_done()
 
55
{
 
56
        ngx_http_lua_pcre_pool = NULL;
 
57
 
 
58
        pcre_malloc = old_pcre_malloc;
 
59
        pcre_free = old_pcre_free;
 
60
}
 
61
 
 
62
#endif /* NGX_PCRE */
 
63
 
 
64
/* vim:set ft=c ts=4 sw=4 et fdm=marker: */
 
65