diff options
author | Igor Sysoev <igor@sysoev.ru> | 2006-02-01 18:22:15 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2006-02-01 18:22:15 +0000 |
commit | 9e58019dc287493e02543d614c975cc14295a71e (patch) | |
tree | 328bccfba6e86794eafc546a7cb7ec8aff007b7f /src/core/ngx_palloc.c | |
parent | e8038c0d1a044f2046d5f7adeb1586d17a5bd81a (diff) | |
download | nginx-release-0.3.24.tar.gz nginx-release-0.3.24.zip |
nginx-0.3.24-RELEASE importrelease-0.3.24
*) Workaround: for bug in FreeBSD kqueue.
*) Bugfix: now a response generated by the "post_action" directive is
not transferred to a client.
*) Bugfix: the memory leaks were occurring if many log files were used.
*) Bugfix: the first "proxy_redirect" directive was working inside one
location.
*) Bugfix: on 64-bit platforms segmentation fault may occurred on start
if the many names were used in the "server_name" directives; the bug
had appeared in 0.3.18.
Diffstat (limited to 'src/core/ngx_palloc.c')
-rw-r--r-- | src/core/ngx_palloc.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/core/ngx_palloc.c b/src/core/ngx_palloc.c index a0229b2ea..eb0e86d0a 100644 --- a/src/core/ngx_palloc.c +++ b/src/core/ngx_palloc.c @@ -221,6 +221,46 @@ ngx_pcalloc(ngx_pool_t *pool, size_t size) } +void * +ngx_shalloc(size_t size) +{ + u_char *p; + + if (size < sizeof(int) || (size & 1)) { + p = ngx_cycle->shm_last; + + } else { + p = ngx_align_ptr(ngx_cycle->shm_last, NGX_ALIGNMENT); + } + + if ((size_t) (ngx_cycle->shm_end - p) >= size) { + ngx_cycle->shm_last = p + size; + return p; + } + + ngx_log_error(NGX_LOG_EMERG, ngx_cycle->log, 0, + "allocation of %uz bytes in shared memory failed, " + "only %uz are available", + size, ngx_cycle->shm_end - ngx_cycle->shm_last); + + return NULL; +} + + +void * +ngx_shcalloc(size_t size) +{ + void *p; + + p = ngx_shalloc(size); + if (p) { + ngx_memzero(p, size); + } + + return p; +} + + ngx_pool_cleanup_t * ngx_pool_cleanup_add(ngx_pool_t *p, size_t size) { |