diff options
author | Igor Sysoev <igor@sysoev.ru> | 2011-10-24 15:46:48 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2011-10-24 15:46:48 +0000 |
commit | efc6ecab8255beedbe2f2148bb4d1dfeadf335b8 (patch) | |
tree | 8b094f0b718cdaeb6c30f129c7dc9664f8702615 /src/os/unix/ngx_darwin_init.c | |
parent | b9c859e6d56710d2db0984e6e2fabef6d0ad2bfc (diff) | |
download | nginx-efc6ecab8255beedbe2f2148bb4d1dfeadf335b8.tar.gz nginx-efc6ecab8255beedbe2f2148bb4d1dfeadf335b8.zip |
malloc() debugging on MacOSX.
Diffstat (limited to 'src/os/unix/ngx_darwin_init.c')
-rw-r--r-- | src/os/unix/ngx_darwin_init.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/os/unix/ngx_darwin_init.c b/src/os/unix/ngx_darwin_init.c index 67133198b..c3d1125fc 100644 --- a/src/os/unix/ngx_darwin_init.c +++ b/src/os/unix/ngx_darwin_init.c @@ -14,6 +14,8 @@ int ngx_darwin_hw_ncpu; int ngx_darwin_kern_ipc_somaxconn; u_long ngx_darwin_net_inet_tcp_sendspace; +ngx_uint_t ngx_debug_malloc; + static ngx_os_io_t ngx_darwin_io = { ngx_unix_recv, @@ -55,6 +57,34 @@ sysctl_t sysctls[] = { }; +void +ngx_debug_init() +{ +#if (NGX_DEBUG_MALLOC) + + /* + * MacOSX 10.6, 10.7: MallocScribble fills freed memory with 0x55 + * and fills allocated memory with 0xAA. + * MacOSX 10.4, 10.5: MallocScribble fills freed memory with 0x55, + * MallocPreScribble fills allocated memory with 0xAA. + * MacOSX 10.3: MallocScribble fills freed memory with 0x55, + * and no way to fill allocated memory. + */ + + setenv("MallocScribble", "1", 0); + + ngx_debug_malloc = 1; + +#else + + if (getenv("MallocScribble")) { + ngx_debug_malloc = 1; + } + +#endif +} + + ngx_int_t ngx_os_specific_init(ngx_log_t *log) { |