diff src/core/ngx_palloc.c @ 138:8e6d4d96ec4c NGINX_0_3_16

nginx 0.3.16 *) Feature: the ngx_http_map_module. *) Feature: the "types_hash_max_size" and "types_hash_bucket_size" directives. *) Feature: the "ssi_value_length" directive. *) Feature: the "worker_rlimit_core" directive. *) Workaround: the connection number in logs was always 1 if nginx was built by the icc 8.1 or 9.0 compilers with optimization for Pentium 4. *) Bugfix: the "config timefmt" SSI command set incorrect time format. *) Bugfix: nginx did not close connection to IMAP/POP3 backend for the SSL connections; bug appeared in 0.3.13. Thanks to Rob Mueller. *) Bugfix: segmentation fault may occurred in at SSL shutdown; bug appeared in 0.3.13.
author Igor Sysoev <http://sysoev.ru>
date Fri, 16 Dec 2005 00:00:00 +0300
parents 91372f004adf
children bb61aa162c6b
line wrap: on
line diff
--- a/src/core/ngx_palloc.c
+++ b/src/core/ngx_palloc.c
@@ -90,10 +90,16 @@ ngx_palloc(ngx_pool_t *pool, size_t size
 
     if (size <= (size_t) NGX_MAX_ALLOC_FROM_POOL
         && size <= (size_t) (pool->end - (u_char *) pool)
-                                     - (size_t) ngx_align(sizeof(ngx_pool_t)))
+                   - (size_t) ngx_align_ptr(sizeof(ngx_pool_t), NGX_ALIGNMENT))
     {
         for (p = pool->current; /* void */ ; p = p->next) {
-            m = ngx_align(p->last);
+
+            if (size < sizeof(int) || (size & 1)) {
+                m = p->last;
+
+            } else {
+                m = ngx_align_ptr(p->last, NGX_ALIGNMENT);
+            }
 
             if ((size_t) (p->end - m) >= size) {
                 p->last = m + size;
@@ -122,7 +128,7 @@ ngx_palloc(ngx_pool_t *pool, size_t size
         }
 
         p->next = n;
-        m = ngx_align(n->last);
+        m = ngx_align_ptr(n->last, NGX_ALIGNMENT);
         n->last = m + size;
 
         return m;