changeset 2049:2a92804f4109

*) back out r2040 *) refactor ngx_palloc() *) introduce ngx_pnalloc() *) additional pool blocks have smaller header
author Igor Sysoev <igor@sysoev.ru>
date Tue, 17 Jun 2008 15:00:30 +0000
parents 824615f3b4ec
children c0bafb136d7b
files src/core/nginx.c src/core/ngx_array.c src/core/ngx_conf_file.c src/core/ngx_connection.c src/core/ngx_cycle.c src/core/ngx_file.c src/core/ngx_hash.c src/core/ngx_inet.c src/core/ngx_palloc.c src/core/ngx_palloc.h src/core/ngx_regex.c src/core/ngx_string.c src/event/ngx_event_accept.c src/event/ngx_event_acceptex.c src/event/ngx_event_openssl.c src/http/modules/ngx_http_auth_basic_module.c src/http/modules/ngx_http_autoindex_module.c src/http/modules/ngx_http_dav_module.c src/http/modules/ngx_http_fastcgi_module.c src/http/modules/ngx_http_gzip_filter_module.c src/http/modules/ngx_http_headers_filter_module.c src/http/modules/ngx_http_index_module.c src/http/modules/ngx_http_log_module.c src/http/modules/ngx_http_map_module.c src/http/modules/ngx_http_proxy_module.c src/http/modules/ngx_http_range_filter_module.c src/http/modules/ngx_http_realip_module.c src/http/modules/ngx_http_ssi_filter_module.c src/http/modules/ngx_http_static_module.c src/http/modules/ngx_http_sub_filter_module.c src/http/modules/ngx_http_userid_filter_module.c src/http/modules/perl/nginx.xs src/http/modules/perl/ngx_http_perl_module.c src/http/ngx_http.c src/http/ngx_http_core_module.c src/http/ngx_http_request.c src/http/ngx_http_script.c src/http/ngx_http_upstream.c src/http/ngx_http_upstream_round_robin.c src/http/ngx_http_variables.c src/mail/ngx_mail.c src/mail/ngx_mail_auth_http_module.c src/mail/ngx_mail_handler.c src/mail/ngx_mail_imap_handler.c src/mail/ngx_mail_imap_module.c src/mail/ngx_mail_pop3_handler.c src/mail/ngx_mail_pop3_module.c src/mail/ngx_mail_proxy_module.c src/mail/ngx_mail_smtp_handler.c src/mail/ngx_mail_smtp_module.c src/mysql/ngx_http_mysql_test.c src/mysql/ngx_mysql.c src/os/unix/ngx_process_cycle.c src/os/unix/ngx_user.c
diffstat 54 files changed, 276 insertions(+), 238 deletions(-) [+]
line wrap: on
line diff
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -826,7 +826,7 @@ ngx_core_module_init_conf(ngx_cycle_t *c
 
     ccf->oldpid.len = ccf->pid.len + sizeof(NGX_OLDPID_EXT);
 
-    ccf->oldpid.data = ngx_palloc(cycle->pool, ccf->oldpid.len);
+    ccf->oldpid.data = ngx_pnalloc(cycle->pool, ccf->oldpid.len);
     if (ccf->oldpid.data == NULL) {
         return NGX_CONF_ERROR;
     }
@@ -870,7 +870,7 @@ ngx_core_module_init_conf(ngx_cycle_t *c
 
     } else {
         cycle->lock_file.len = ccf->lock_file.len + 1;
-        cycle->lock_file.data = ngx_palloc(cycle->pool,
+        cycle->lock_file.data = ngx_pnalloc(cycle->pool,
                                       ccf->lock_file.len + sizeof(".accept"));
         if (cycle->lock_file.data == NULL) {
             return NGX_CONF_ERROR;
--- a/src/core/ngx_array.c
+++ b/src/core/ngx_array.c
@@ -39,12 +39,12 @@ ngx_array_destroy(ngx_array_t *a)
 
     p = a->pool;
 
-    if ((u_char *) a->elts + a->size * a->nalloc == p->last) {
-        p->last -= a->size * a->nalloc;
+    if ((u_char *) a->elts + a->size * a->nalloc == p->d.last) {
+        p->d.last -= a->size * a->nalloc;
     }
 
-    if ((u_char *) a + sizeof(ngx_array_t) == p->last) {
-        p->last = (u_char *) a;
+    if ((u_char *) a + sizeof(ngx_array_t) == p->d.last) {
+        p->d.last = (u_char *) a;
     }
 }
 
@@ -64,14 +64,15 @@ ngx_array_push(ngx_array_t *a)
 
         p = a->pool;
 
-        if ((u_char *) a->elts + size == p->last && p->last + a->size <= p->end)
+        if ((u_char *) a->elts + size == p->d.last
+            && p->d.last + a->size <= p->d.end)
         {
             /*
              * the array allocation is the last in the pool
              * and there is space for new allocation
              */
 
-            p->last += a->size;
+            p->d.last += a->size;
             a->nalloc++;
 
         } else {
@@ -111,15 +112,15 @@ ngx_array_push_n(ngx_array_t *a, ngx_uin
 
         p = a->pool;
 
-        if ((u_char *) a->elts + a->size * a->nalloc == p->last
-            && p->last + size <= p->end)
+        if ((u_char *) a->elts + a->size * a->nalloc == p->d.last
+            && p->d.last + size <= p->d.end)
         {
             /*
              * the array allocation is the last in the pool
              * and there is space for new allocation
              */
 
-            p->last += size;
+            p->d.last += size;
             a->nalloc += n;
 
         } else {
--- a/src/core/ngx_conf_file.c
+++ b/src/core/ngx_conf_file.c
@@ -574,7 +574,7 @@ ngx_conf_read_token(ngx_conf_t *cf)
                     return NGX_ERROR;
                 }
 
-                word->data = ngx_palloc(cf->pool, b->pos - start + 1);
+                word->data = ngx_pnalloc(cf->pool, b->pos - start + 1);
                 if (word->data == NULL) {
                     return NGX_ERROR;
                 }
@@ -726,7 +726,7 @@ ngx_conf_full_name(ngx_cycle_t *cycle, n
     }
 
     name->len = len + old.len;
-    name->data = ngx_palloc(cycle->pool, name->len + 1);
+    name->data = ngx_pnalloc(cycle->pool, name->len + 1);
     if (name->data == NULL) {
         return  NGX_ERROR;
     }
--- a/src/core/ngx_connection.c
+++ b/src/core/ngx_connection.c
@@ -36,7 +36,7 @@ ngx_listening_inet_stream_socket(ngx_con
     sin->sin_port = htons(port);
 
 
-    ls->addr_text.data = ngx_palloc(cf->pool,
+    ls->addr_text.data = ngx_pnalloc(cf->pool,
                                     INET_ADDRSTRLEN - 1 + sizeof(":65535") - 1);
     if (ls->addr_text.data == NULL) {
         return NULL;
@@ -106,8 +106,8 @@ ngx_set_inherited_sockets(ngx_cycle_t *c
 
         ls[i].addr_text_max_len = INET_ADDRSTRLEN;
 
-        ls[i].addr_text.data = ngx_palloc(cycle->pool, INET_ADDRSTRLEN - 1
-                                                       + sizeof(":65535") - 1);
+        ls[i].addr_text.data = ngx_pnalloc(cycle->pool,
+                                   INET_ADDRSTRLEN - 1 + sizeof(":65535") - 1);
         if (ls[i].addr_text.data == NULL) {
             return NGX_ERROR;
         }
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -81,7 +81,7 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
 
 
     cycle->conf_file.len = old_cycle->conf_file.len;
-    cycle->conf_file.data = ngx_palloc(pool, old_cycle->conf_file.len + 1);
+    cycle->conf_file.data = ngx_pnalloc(pool, old_cycle->conf_file.len + 1);
     if (cycle->conf_file.data == NULL) {
         ngx_destroy_pool(pool);
         return NULL;
@@ -182,7 +182,7 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
     hostname[NGX_MAXHOSTNAMELEN - 1] = '\0';
     cycle->hostname.len = ngx_strlen(hostname);
 
-    cycle->hostname.data = ngx_palloc(pool, cycle->hostname.len);
+    cycle->hostname.data = ngx_pnalloc(pool, cycle->hostname.len);
     if (cycle->hostname.data == NULL) {
         ngx_destroy_pool(pool);
         return NULL;
@@ -460,8 +460,8 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
 
 #else
 
-        lock_file = ngx_palloc(cycle->pool,
-                               cycle->lock_file.len + shm_zone[i].name.len);
+        lock_file = ngx_pnalloc(cycle->pool,
+                                cycle->lock_file.len + shm_zone[i].name.len);
 
         if (lock_file == NULL) {
             goto failed;
--- a/src/core/ngx_file.c
+++ b/src/core/ngx_file.c
@@ -46,7 +46,7 @@ ngx_create_temp_file(ngx_file_t *file, n
 
     file->name.len = path->name.len + 1 + path->len + 10;
 
-    file->name.data = ngx_palloc(pool, file->name.len + 1);
+    file->name.data = ngx_pnalloc(pool, file->name.len + 1);
     if (file->name.data == NULL) {
         return NGX_ERROR;
     }
--- a/src/core/ngx_hash.c
+++ b/src/core/ngx_hash.c
@@ -839,7 +839,7 @@ wildcard:
         }
 
         name->len = last - 1;
-        name->data = ngx_palloc(ha->temp_pool, name->len);
+        name->data = ngx_pnalloc(ha->temp_pool, name->len);
         if (name->data == NULL) {
             return NGX_ERROR;
         }
@@ -855,7 +855,7 @@ wildcard:
          *      and ".example.com" to "com.example\0"
          */
 
-        p = ngx_palloc(ha->temp_pool, last);
+        p = ngx_pnalloc(ha->temp_pool, last);
         if (p == NULL) {
             return NGX_ERROR;
         }
@@ -891,7 +891,7 @@ wildcard:
 
         last++;
 
-        p = ngx_palloc(ha->temp_pool, last);
+        p = ngx_pnalloc(ha->temp_pool, last);
         if (p == NULL) {
             return NGX_ERROR;
         }
@@ -944,7 +944,7 @@ wildcard:
     }
 
     name->len = last - skip;
-    name->data = ngx_palloc(ha->temp_pool, name->len);
+    name->data = ngx_pnalloc(ha->temp_pool, name->len);
     if (name->data == NULL) {
         return NGX_ERROR;
     }
--- a/src/core/ngx_inet.c
+++ b/src/core/ngx_inet.c
@@ -578,7 +578,7 @@ ngx_inet_resolve_host(ngx_pool_t *pool, 
 
             len = INET_ADDRSTRLEN - 1 + 1 + sizeof(":65536") - 1;
 
-            p = ngx_palloc(pool, len);
+            p = ngx_pnalloc(pool, len);
             if (p == NULL) {
                 return NGX_ERROR;
             }
@@ -614,7 +614,7 @@ ngx_inet_resolve_host(ngx_pool_t *pool, 
         u->addrs[0].sockaddr = (struct sockaddr *) sin;
         u->addrs[0].socklen = sizeof(struct sockaddr_in);
 
-        p = ngx_palloc(pool, u->host.len + sizeof(":65536") - 1);
+        p = ngx_pnalloc(pool, u->host.len + sizeof(":65536") - 1);
         if (p == NULL) {
             return NGX_ERROR;
         }
--- a/src/core/ngx_palloc.c
+++ b/src/core/ngx_palloc.c
@@ -8,6 +8,10 @@
 #include <ngx_core.h>
 
 
+static void *ngx_palloc_block(ngx_pool_t *pool, size_t size);
+static void *ngx_palloc_large(ngx_pool_t *pool, size_t size);
+
+
 ngx_pool_t *
 ngx_create_pool(size_t size, ngx_log_t *log)
 {
@@ -18,11 +22,14 @@ ngx_create_pool(size_t size, ngx_log_t *
         return NULL;
     }
 
-    p->last = (u_char *) p + sizeof(ngx_pool_t);
-    p->end = (u_char *) p + size;
+    p->d.last = (u_char *) p + sizeof(ngx_pool_t);
+    p->d.end = (u_char *) p + size;
+    p->d.next = NULL;
+
+    p->max = (size < NGX_MAX_ALLOC_FROM_POOL) ? size - sizeof(ngx_pool_t):
+                                                NGX_MAX_ALLOC_FROM_POOL;
     p->current = p;
     p->chain = NULL;
-    p->next = NULL;
     p->large = NULL;
     p->cleanup = NULL;
     p->log = log;
@@ -62,9 +69,9 @@ ngx_destroy_pool(ngx_pool_t *pool)
      * so we can not use this log while the free()ing the pool
      */
 
-    for (p = pool, n = pool->next; /* void */; p = n, n = n->next) {
+    for (p = pool, n = pool->d.next; /* void */; p = n, n = n->d.next) {
         ngx_log_debug2(NGX_LOG_DEBUG_ALLOC, pool->log, 0,
-                       "free: %p, unused: %uz", p, p->end - p->last);
+                       "free: %p, unused: %uz", p, p->d.end - p->d.last);
 
         if (n == NULL) {
             break;
@@ -73,7 +80,7 @@ ngx_destroy_pool(ngx_pool_t *pool)
 
 #endif
 
-    for (p = pool, n = pool->next; /* void */; p = n, n = n->next) {
+    for (p = pool, n = pool->d.next; /* void */; p = n, n = n->d.next) {
         ngx_free(p);
 
         if (n == NULL) {
@@ -86,65 +93,98 @@ ngx_destroy_pool(ngx_pool_t *pool)
 void *
 ngx_palloc(ngx_pool_t *pool, size_t size)
 {
-    u_char            *m;
-    ngx_pool_t        *p, *n, *current;
-    ngx_pool_large_t  *large;
+    u_char      *m;
+    ngx_pool_t  *p;
 
-    if (size <= (size_t) NGX_MAX_ALLOC_FROM_POOL
-        && size <= (size_t) (pool->end - (u_char *) pool)
-                   - (size_t) ngx_align_ptr(sizeof(ngx_pool_t), NGX_ALIGNMENT))
-    {
+    if (size <= pool->max) {
+
         p = pool->current;
-        current = p;
 
-        for ( ;; ) {
+        do {
+            m = ngx_align_ptr(p->d.last, NGX_ALIGNMENT);
 
-            /*
-             * allow non-aligned memory blocks for small allocations (1, 2,
-             * or 3 bytes) and for odd length strings (struct's have aligned
-             * size)
-             */
+            if ((size_t) (p->d.end - m) >= size) {
+                p->d.last = m + size;
 
-            if (size < sizeof(int) || (size & 1)) {
-                m = p->last;
-
-            } else {
-                m = ngx_align_ptr(p->last, NGX_ALIGNMENT);
+                return m;
             }
 
-            if ((size_t) (p->end - m) >= size) {
-                p->last = m + size;
+            p = p->d.next;
+
+        } while (p);
+
+        return ngx_palloc_block(pool, size);
+    }
+
+    return ngx_palloc_large(pool, size);
+}
+
+
+void *
+ngx_pnalloc(ngx_pool_t *pool, size_t size)
+{
+    u_char      *m;
+    ngx_pool_t  *p;
+
+    if (size <= pool->max) {
+
+        p = pool->current;
+
+        do {
+            m = p->d.last;
+
+            if ((size_t) (p->d.end - m) >= size) {
+                p->d.last = m + size;
 
                 return m;
             }
 
-            if ((size_t) (p->end - m) < NGX_ALIGNMENT) {
-                current = p->next;
-            }
+            p = p->d.next;
+
+        } while (p);
+
+        return ngx_palloc_block(pool, size);
+    }
+
+    return ngx_palloc_large(pool, size);
+}
+
 
-            if (p->next == NULL) {
-                break;
-            }
+static void *
+ngx_palloc_block(ngx_pool_t *pool, size_t size)
+{
+    u_char      *m;
+    ngx_pool_t  *p, *new, *current;
 
-            p = p->next;
-            pool->current = current;
-        }
-
-        /* allocate a new pool block */
+    new = ngx_create_pool((size_t) (pool->d.end - (u_char *) pool), pool->log);
+    if (new == NULL) {
+        return NULL;
+    }
 
-        n = ngx_create_pool((size_t) (p->end - (u_char *) p), p->log);
-        if (n == NULL) {
-            return NULL;
+    current = pool->current;
+
+    for (p = current; p->d.next; p = p->d.next) {
+        if ((size_t) (p->d.end - p->d.last) < NGX_ALIGNMENT) {
+            current = p->d.next;
         }
+    }
 
-        pool->current = current ? current : n;
+    p->d.next = new;
+
+    pool->current = current ? current : new;
 
-        p->next = n;
-        m = ngx_align_ptr(n->last, NGX_ALIGNMENT);
-        n->last = m + size;
+    m = (u_char *) new + sizeof(ngx_pool_data_t);
+    new->d.last = m + size;
+
+    return m;
+}
 
-        return m;
-    }
+
+static void *
+ngx_palloc_large(ngx_pool_t *pool, size_t size)
+{
+    void              *p;
+    ngx_pool_large_t  *large;
 
 #if 0
     p = ngx_memalign(ngx_pagesize, size, pool->log);
@@ -172,17 +212,6 @@ ngx_palloc(ngx_pool_t *pool, size_t size
 }
 
 
-void *
-ngx_palloc_aligned(ngx_pool_t *pool, size_t size)
-{
-    if (size & 1) {
-        size++;
-    }
-
-    return ngx_palloc(pool, size);
-}
-
-
 ngx_int_t
 ngx_pfree(ngx_pool_t *pool, void *p)
 {
--- a/src/core/ngx_palloc.h
+++ b/src/core/ngx_palloc.h
@@ -43,12 +43,18 @@ struct ngx_pool_large_s {
 };
 
 
-struct ngx_pool_s {
+typedef struct {
     u_char               *last;
     u_char               *end;
+    ngx_pool_t           *next;
+} ngx_pool_data_t;
+
+
+struct ngx_pool_s {
+    ngx_pool_data_t       d;
+    size_t                max;
     ngx_pool_t           *current;
     ngx_chain_t          *chain;
-    ngx_pool_t           *next;
     ngx_pool_large_t     *large;
     ngx_pool_cleanup_t   *cleanup;
     ngx_log_t            *log;
@@ -69,7 +75,7 @@ ngx_pool_t *ngx_create_pool(size_t size,
 void ngx_destroy_pool(ngx_pool_t *pool);
 
 void *ngx_palloc(ngx_pool_t *pool, size_t size);
-void *ngx_palloc_aligned(ngx_pool_t *pool, size_t size);
+void *ngx_pnalloc(ngx_pool_t *pool, size_t size);
 void *ngx_pcalloc(ngx_pool_t *pool, size_t size);
 ngx_int_t ngx_pfree(ngx_pool_t *pool, void *p);
 
--- a/src/core/ngx_regex.c
+++ b/src/core/ngx_regex.c
@@ -165,7 +165,7 @@ ngx_regex_malloc(size_t size)
 #endif
 
     if (pool) {
-        return ngx_palloc_aligned(pool, size);
+        return ngx_palloc(pool, size);
     }
 
     return NULL;
--- a/src/core/ngx_string.c
+++ b/src/core/ngx_string.c
@@ -34,7 +34,7 @@ ngx_pstrdup(ngx_pool_t *pool, ngx_str_t 
 {
     u_char  *dst;
 
-    dst = ngx_palloc(pool, src->len);
+    dst = ngx_pnalloc(pool, src->len);
     if (dst == NULL) {
         return NULL;
     }
--- a/src/event/ngx_event_accept.c
+++ b/src/event/ngx_event_accept.c
@@ -201,7 +201,7 @@ ngx_event_accept(ngx_event_t *ev)
 #endif
 
         if (ls->addr_ntop) {
-            c->addr_text.data = ngx_palloc(c->pool, ls->addr_text_max_len);
+            c->addr_text.data = ngx_pnalloc(c->pool, ls->addr_text_max_len);
             if (c->addr_text.data == NULL) {
                 ngx_close_accepted_connection(c);
                 return;
--- a/src/event/ngx_event_acceptex.c
+++ b/src/event/ngx_event_acceptex.c
@@ -58,8 +58,8 @@ ngx_event_acceptex(ngx_event_t *rev)
     }
 
     if (c->listening->addr_ntop) {
-        c->addr_text.data = ngx_palloc(c->pool,
-                                       c->listening->addr_text_max_len);
+        c->addr_text.data = ngx_pnalloc(c->pool,
+                                        c->listening->addr_text_max_len);
         if (c->addr_text.data == NULL) {
             /* TODO: close socket */
             return;
--- a/src/event/ngx_event_openssl.c
+++ b/src/event/ngx_event_openssl.c
@@ -1907,7 +1907,7 @@ ngx_ssl_get_certificate(ngx_connection_t
     len = BIO_pending(bio);
     s->len = len;
 
-    s->data = ngx_palloc(pool, len);
+    s->data = ngx_pnalloc(pool, len);
     if (s->data == NULL) {
         goto failed;
     }
@@ -1954,7 +1954,7 @@ ngx_ssl_get_subject_dn(ngx_connection_t 
     for (len = 0; p[len]; len++) { /* void */ }
 
     s->len = len;
-    s->data = ngx_palloc(pool, len);
+    s->data = ngx_pnalloc(pool, len);
     if (s->data == NULL) {
         OPENSSL_free(p);
         X509_free(cert);
@@ -1996,7 +1996,7 @@ ngx_ssl_get_issuer_dn(ngx_connection_t *
     for (len = 0; p[len]; len++) { /* void */ }
 
     s->len = len;
-    s->data = ngx_palloc(pool, len);
+    s->data = ngx_pnalloc(pool, len);
     if (s->data == NULL) {
         OPENSSL_free(p);
         X509_free(cert);
@@ -2036,7 +2036,7 @@ ngx_ssl_get_serial_number(ngx_connection
     len = BIO_pending(bio);
 
     s->len = len;
-    s->data = ngx_palloc(pool, len);
+    s->data = ngx_pnalloc(pool, len);
     if (s->data == NULL) {
         BIO_free(bio);
         X509_free(cert);
--- a/src/http/modules/ngx_http_auth_basic_module.c
+++ b/src/http/modules/ngx_http_auth_basic_module.c
@@ -232,7 +232,7 @@ ngx_http_auth_basic_handler(ngx_http_req
 
     if (state == sw_passwd) {
         pwd.len = i - passwd;
-        pwd.data = ngx_palloc(r->pool, pwd.len + 1);
+        pwd.data = ngx_pnalloc(r->pool, pwd.len + 1);
         if (pwd.data == NULL) {
             return NGX_HTTP_INTERNAL_SERVER_ERROR;
         }
@@ -400,7 +400,7 @@ ngx_http_auth_basic(ngx_conf_t *cf, void
 
     len = sizeof("Basic realm=\"") - 1 + realm->len + 1;
 
-    basic = ngx_palloc(cf->pool, len);
+    basic = ngx_pnalloc(cf->pool, len);
     if (basic == NULL) {
         return NGX_CONF_ERROR;
     }
--- a/src/http/modules/ngx_http_autoindex_module.c
+++ b/src/http/modules/ngx_http_autoindex_module.c
@@ -282,7 +282,7 @@ ngx_http_autoindex_handler(ngx_http_requ
                 allocated = path.len + 1 + len + 1
                                      + NGX_HTTP_AUTOINDEX_PREALLOCATE;
 
-                filename = ngx_palloc(pool, allocated);
+                filename = ngx_pnalloc(pool, allocated);
                 if (filename == NULL) {
                     return ngx_http_autoindex_error(r, &dir, &path);
                 }
@@ -318,7 +318,7 @@ ngx_http_autoindex_handler(ngx_http_requ
 
         entry->name.len = len;
 
-        entry->name.data = ngx_palloc(pool, len + 1);
+        entry->name.data = ngx_pnalloc(pool, len + 1);
         if (entry->name.data == NULL) {
             return ngx_http_autoindex_error(r, &dir, &path);
         }
--- a/src/http/modules/ngx_http_dav_module.c
+++ b/src/http/modules/ngx_http_dav_module.c
@@ -1102,7 +1102,7 @@ ngx_http_dav_location(ngx_http_request_t
         location = path + clcf->root.len;
 
     } else {
-        location = ngx_palloc(r->pool, r->uri.len);
+        location = ngx_pnalloc(r->pool, r->uri.len);
         if (location == NULL) {
             return NGX_ERROR;
         }
--- a/src/http/modules/ngx_http_fastcgi_module.c
+++ b/src/http/modules/ngx_http_fastcgi_module.c
@@ -1059,7 +1059,7 @@ ngx_http_fastcgi_process_header(ngx_http
                         size += part[i].end - part[i].start;
                     }
 
-                    p = ngx_palloc(r->pool, size);
+                    p = ngx_pnalloc(r->pool, size);
                     if (p == NULL) {
                         return NGX_ERROR;
                     }
@@ -1087,7 +1087,7 @@ ngx_http_fastcgi_process_header(ngx_http
                     h->value.data = r->header_start;
                     h->value.data[h->value.len] = '\0';
 
-                    h->lowcase_key = ngx_palloc(r->pool, h->key.len);
+                    h->lowcase_key = ngx_pnalloc(r->pool, h->key.len);
                     if (h->lowcase_key == NULL) {
                         return NGX_ERROR;
                     }
@@ -1097,9 +1097,9 @@ ngx_http_fastcgi_process_header(ngx_http
                     h->key.len = r->header_name_end - r->header_name_start;
                     h->value.len = r->header_end - r->header_start;
 
-                    h->key.data = ngx_palloc(r->pool,
-                                             h->key.len + 1 + h->value.len + 1
-                                             + h->key.len);
+                    h->key.data = ngx_pnalloc(r->pool,
+                                              h->key.len + 1 + h->value.len + 1
+                                              + h->key.len);
                     if (h->key.data == NULL) {
                         return NGX_ERROR;
                     }
@@ -2015,7 +2015,7 @@ ngx_http_fastcgi_script_name_variable(ng
 
         v->len = r->uri.len + flcf->index.len;
 
-        v->data = ngx_palloc(r->pool, v->len);
+        v->data = ngx_pnalloc(r->pool, v->len);
         if (v->data == NULL) {
             return NGX_ERROR;
         }
--- a/src/http/modules/ngx_http_gzip_filter_module.c
+++ b/src/http/modules/ngx_http_gzip_filter_module.c
@@ -802,7 +802,7 @@ ngx_http_gzip_ratio_variable(ngx_http_re
         return NGX_OK;
     }
 
-    v->data = ngx_palloc(r->pool, NGX_INT32_LEN + 3);
+    v->data = ngx_pnalloc(r->pool, NGX_INT32_LEN + 3);
     if (v->data == NULL) {
         return NGX_ERROR;
     }
@@ -951,7 +951,7 @@ ngx_http_gzip_types(ngx_conf_t *cf, ngx_
 
         type->len = value[i].len;
 
-        type->data = ngx_palloc(cf->pool, type->len + 1);
+        type->data = ngx_pnalloc(cf->pool, type->len + 1);
         if (type->data == NULL) {
             return NGX_CONF_ERROR;
         }
--- a/src/http/modules/ngx_http_headers_filter_module.c
+++ b/src/http/modules/ngx_http_headers_filter_module.c
@@ -264,7 +264,7 @@ ngx_http_set_expires(ngx_http_request_t 
         return NGX_OK;
     }
 
-    expires->value.data = ngx_palloc(r->pool, len);
+    expires->value.data = ngx_pnalloc(r->pool, len);
     if (expires->value.data == NULL) {
         return NGX_ERROR;
     }
@@ -297,8 +297,8 @@ ngx_http_set_expires(ngx_http_request_t 
         return NGX_OK;
     }
 
-    cc->value.data = ngx_palloc(r->pool,
-                                sizeof("max-age=") + NGX_TIME_T_LEN + 1);
+    cc->value.data = ngx_pnalloc(r->pool,
+                                 sizeof("max-age=") + NGX_TIME_T_LEN + 1);
     if (cc->value.data == NULL) {
         return NGX_ERROR;
     }
--- a/src/http/modules/ngx_http_index_module.c
+++ b/src/http/modules/ngx_http_index_module.c
@@ -254,7 +254,7 @@ ngx_http_index_handler(ngx_http_request_
             uri.data = path.data + root;
 
         } else {
-            uri.data = ngx_palloc(r->pool, uri.len);
+            uri.data = ngx_pnalloc(r->pool, uri.len);
             if (uri.data == NULL) {
                 return NGX_HTTP_INTERNAL_SERVER_ERROR;
             }
--- a/src/http/modules/ngx_http_log_module.c
+++ b/src/http/modules/ngx_http_log_module.c
@@ -261,7 +261,7 @@ ngx_http_log_handler(ngx_http_request_t 
             }
         }
 
-        line = ngx_palloc(r->pool, len);
+        line = ngx_pnalloc(r->pool, len);
         if (line == NULL) {
             return NGX_ERROR;
         }
@@ -970,7 +970,7 @@ ngx_http_log_compile_format(ngx_conf_t *
                 } else {
                     op->run = ngx_http_log_copy_long;
 
-                    p = ngx_palloc(cf->pool, len);
+                    p = ngx_pnalloc(cf->pool, len);
                     if (p == NULL) {
                         return NGX_CONF_ERROR;
                     }
--- a/src/http/modules/ngx_http_map_module.c
+++ b/src/http/modules/ngx_http_map_module.c
@@ -130,7 +130,7 @@ ngx_http_map_variable(ngx_http_request_t
         return NGX_OK;
     }
 
-    name = ngx_palloc(r->pool, len);
+    name = ngx_pnalloc(r->pool, len);
     if (name == NULL) {
         return NGX_ERROR;
     }
--- a/src/http/modules/ngx_http_proxy_module.c
+++ b/src/http/modules/ngx_http_proxy_module.c
@@ -964,8 +964,8 @@ ngx_http_proxy_process_status_line(ngx_h
     u->state->status = ctx->status;
 
     u->headers_in.status_line.len = ctx->status_end - ctx->status_start;
-    u->headers_in.status_line.data = ngx_palloc(r->pool,
-                                                u->headers_in.status_line.len);
+    u->headers_in.status_line.data = ngx_pnalloc(r->pool,
+                                                 u->headers_in.status_line.len);
     if (u->headers_in.status_line.data == NULL) {
         return NGX_ERROR;
     }
@@ -1220,7 +1220,7 @@ ngx_http_proxy_process_header(ngx_http_r
             h->key.len = r->header_name_end - r->header_name_start;
             h->value.len = r->header_end - r->header_start;
 
-            h->key.data = ngx_palloc(r->pool,
+            h->key.data = ngx_pnalloc(r->pool,
                                h->key.len + 1 + h->value.len + 1 + h->key.len);
             if (h->key.data == NULL) {
                 return NGX_ERROR;
@@ -1400,7 +1400,7 @@ ngx_http_proxy_add_x_forwarded_for_varia
     v->len = r->headers_in.x_forwarded_for->value.len
              + sizeof(", ") - 1 + r->connection->addr_text.len;
 
-    p = ngx_palloc(r->pool, v->len);
+    p = ngx_pnalloc(r->pool, v->len);
     if (p == NULL) {
         return NGX_ERROR;
     }
@@ -1435,7 +1435,7 @@ ngx_http_proxy_internal_body_length_vari
     v->no_cacheable = 0;
     v->not_found = 0;
 
-    v->data = ngx_palloc(r->connection->pool, NGX_SIZE_T_LEN);
+    v->data = ngx_pnalloc(r->connection->pool, NGX_SIZE_T_LEN);
 
     if (v->data == NULL) {
         return NGX_ERROR;
@@ -1492,7 +1492,7 @@ ngx_http_proxy_rewrite_redirect_text(ngx
 
     len = prefix + pr->replacement.text.len + h->value.len - pr->redirect.len;
 
-    data = ngx_palloc(r->pool, len);
+    data = ngx_pnalloc(r->pool, len);
     if (data == NULL) {
         return NGX_ERROR;
     }
@@ -1544,7 +1544,7 @@ ngx_http_proxy_rewrite_redirect_vars(ngx
         len += lcode(&e);
     }
 
-    data = ngx_palloc(r->pool, len);
+    data = ngx_pnalloc(r->pool, len);
     if (data == NULL) {
         return NGX_ERROR;
     }
--- a/src/http/modules/ngx_http_range_filter_module.c
+++ b/src/http/modules/ngx_http_range_filter_module.c
@@ -307,7 +307,7 @@ ngx_http_range_header_filter(ngx_http_re
         content_range->key.len = sizeof("Content-Range") - 1;
         content_range->key.data = (u_char *) "Content-Range";
 
-        content_range->value.data = ngx_palloc(r->pool,
+        content_range->value.data = ngx_pnalloc(r->pool,
                                        sizeof("bytes */") - 1 + NGX_OFF_T_LEN);
         if (content_range->value.data == NULL) {
             return NGX_ERROR;
@@ -341,7 +341,7 @@ ngx_http_range_header_filter(ngx_http_re
         content_range->key.data = (u_char *) "Content-Range";
 
         content_range->value.data =
-               ngx_palloc(r->pool, sizeof("bytes -/") - 1 + 3 * NGX_OFF_T_LEN);
+              ngx_pnalloc(r->pool, sizeof("bytes -/") - 1 + 3 * NGX_OFF_T_LEN);
         if (content_range->value.data == NULL) {
             return NGX_ERROR;
         }
@@ -376,7 +376,7 @@ ngx_http_range_header_filter(ngx_http_re
         len += sizeof("; charset=") - 1 + r->headers_out.charset.len;
     }
 
-    ctx->boundary_header.data = ngx_palloc(r->pool, len);
+    ctx->boundary_header.data = ngx_pnalloc(r->pool, len);
     if (ctx->boundary_header.data == NULL) {
         return NGX_ERROR;
     }
@@ -414,9 +414,9 @@ ngx_http_range_header_filter(ngx_http_re
     }
 
     r->headers_out.content_type.data =
-        ngx_palloc(r->pool,
-                   sizeof("Content-Type: multipart/byteranges; boundary=") - 1
-                   + NGX_ATOMIC_T_LEN);
+        ngx_pnalloc(r->pool,
+                    sizeof("Content-Type: multipart/byteranges; boundary=") - 1
+                    + NGX_ATOMIC_T_LEN);
 
     if (r->headers_out.content_type.data == NULL) {
         return NGX_ERROR;
@@ -441,7 +441,7 @@ ngx_http_range_header_filter(ngx_http_re
         /* the size of the range: "SSSS-EEEE/TTTT" CRLF CRLF */
 
         range[i].content_range.data =
-                                ngx_palloc(r->pool, 3 * NGX_OFF_T_LEN + 2 + 4);
+                               ngx_pnalloc(r->pool, 3 * NGX_OFF_T_LEN + 2 + 4);
 
         if (range[i].content_range.data == NULL) {
             return NGX_ERROR;
@@ -649,8 +649,8 @@ ngx_http_range_body_filter(ngx_http_requ
     b->temporary = 1;
     b->last_buf = 1;
 
-    b->pos = ngx_palloc(r->pool, sizeof(CRLF "--") - 1 + NGX_ATOMIC_T_LEN
-                                 + sizeof("--" CRLF) - 1);
+    b->pos = ngx_pnalloc(r->pool, sizeof(CRLF "--") - 1 + NGX_ATOMIC_T_LEN
+                                  + sizeof("--" CRLF) - 1);
     if (b->pos == NULL) {
         return NGX_ERROR;
     }
--- a/src/http/modules/ngx_http_realip_module.c
+++ b/src/http/modules/ngx_http_realip_module.c
@@ -163,7 +163,7 @@ ngx_http_realip_handler(ngx_http_request
                 return NGX_DECLINED;
             }
 
-            p = ngx_palloc(r->connection->pool, len);
+            p = ngx_pnalloc(r->connection->pool, len);
             if (p == NULL) {
                 return NGX_HTTP_INTERNAL_SERVER_ERROR;
             }
--- a/src/http/modules/ngx_http_ssi_filter_module.c
+++ b/src/http/modules/ngx_http_ssi_filter_module.c
@@ -1151,8 +1151,8 @@ ngx_http_ssi_parse(ngx_http_request_t *r
 
             default:
                 ctx->command.len = 1;
-                ctx->command.data = ngx_palloc(r->pool,
-                                               NGX_HTTP_SSI_COMMAND_LEN);
+                ctx->command.data = ngx_pnalloc(r->pool,
+                                                NGX_HTTP_SSI_COMMAND_LEN);
                 if (ctx->command.data == NULL) {
                     return NGX_ERROR;
                 }
@@ -1218,8 +1218,8 @@ ngx_http_ssi_parse(ngx_http_request_t *r
                 }
 
                 ctx->param->key.len = 1;
-                ctx->param->key.data = ngx_palloc(r->pool,
-                                                  NGX_HTTP_SSI_PARAM_LEN);
+                ctx->param->key.data = ngx_pnalloc(r->pool,
+                                                   NGX_HTTP_SSI_PARAM_LEN);
                 if (ctx->param->key.data == NULL) {
                     return NGX_ERROR;
                 }
@@ -1229,8 +1229,8 @@ ngx_http_ssi_parse(ngx_http_request_t *r
                 ctx->param->value.len = 0;
 
                 if (ctx->value_buf == NULL) {
-                    ctx->param->value.data = ngx_palloc(r->pool,
-                                                        ctx->value_len);
+                    ctx->param->value.data = ngx_pnalloc(r->pool,
+                                                         ctx->value_len);
                     if (ctx->param->value.data == NULL) {
                         return NGX_ERROR;
                     }
@@ -1408,7 +1408,7 @@ ngx_http_ssi_parse(ngx_http_request_t *r
         case ssi_postparam_state:
 
             if (ctx->param->value.len + 1 < ctx->value_len / 2) {
-                value = ngx_palloc(r->pool, ctx->param->value.len + 1);
+                value = ngx_pnalloc(r->pool, ctx->param->value.len + 1);
                 if (value == NULL) {
                     return NGX_ERROR;
                 }
@@ -1626,7 +1626,7 @@ ngx_http_ssi_evaluate_string(ngx_http_re
             if (prefix) {
                 len = prefix + text->len;
 
-                data = ngx_palloc(r->pool, len);
+                data = ngx_pnalloc(r->pool, len);
                 if (data == NULL) {
                     return NGX_ERROR;
                 }
@@ -1829,7 +1829,7 @@ ngx_http_ssi_evaluate_string(ngx_http_re
         }
     }
 
-    p = ngx_palloc(r->pool, len + ((flags & NGX_HTTP_SSI_ADD_ZERO) ? 1 : 0));
+    p = ngx_pnalloc(r->pool, len + ((flags & NGX_HTTP_SSI_ADD_ZERO) ? 1 : 0));
     if (p == NULL) {
         return NGX_ERROR;
     }
@@ -2222,7 +2222,7 @@ ngx_http_ssi_echo(ngx_http_request_t *r,
                                  NGX_ESCAPE_HTML);
 
         if (len) {
-            p = ngx_palloc(r->pool, value->len + len);
+            p = ngx_pnalloc(r->pool, value->len + len);
             if (p == NULL) {
                 return NGX_HTTP_SSI_ERROR;
             }
@@ -2239,7 +2239,7 @@ ngx_http_ssi_echo(ngx_http_request_t *r,
         len = ngx_escape_html(NULL, value->data, value->len);
 
         if (len) {
-            p = ngx_palloc(r->pool, value->len + len);
+            p = ngx_pnalloc(r->pool, value->len + len);
             if (p == NULL) {
                 return NGX_HTTP_SSI_ERROR;
             }
@@ -2286,7 +2286,7 @@ ngx_http_ssi_config(ngx_http_request_t *
 
     if (value) {
         ctx->timefmt.len = value->len;
-        ctx->timefmt.data = ngx_palloc(r->pool, value->len + 1);
+        ctx->timefmt.data = ngx_pnalloc(r->pool, value->len + 1);
         if (ctx->timefmt.data == NULL) {
             return NGX_HTTP_SSI_ERROR;
         }
@@ -2666,7 +2666,7 @@ ngx_http_ssi_date_gmt_local_variable(ngx
         || (ctx->timefmt.len == sizeof("%s") - 1
             && ctx->timefmt.data[0] == '%' && ctx->timefmt.data[1] == 's'))
     {
-        v->data = ngx_palloc(r->pool, NGX_TIME_T_LEN);
+        v->data = ngx_pnalloc(r->pool, NGX_TIME_T_LEN);
         if (v->data == NULL) {
             return NGX_ERROR;
         }
@@ -2689,7 +2689,7 @@ ngx_http_ssi_date_gmt_local_variable(ngx
         return NGX_ERROR;
     }
 
-    v->data = ngx_palloc(r->pool, v->len);
+    v->data = ngx_pnalloc(r->pool, v->len);
     if (v->data == NULL) {
         return NGX_ERROR;
     }
@@ -2738,7 +2738,7 @@ ngx_http_ssi_types(ngx_conf_t *cf, ngx_c
 
         type->len = value[i].len;
 
-        type->data = ngx_palloc(cf->pool, type->len + 1);
+        type->data = ngx_pnalloc(cf->pool, type->len + 1);
         if (type->data == NULL) {
             return NGX_CONF_ERROR;
         }
--- a/src/http/modules/ngx_http_static_module.c
+++ b/src/http/modules/ngx_http_static_module.c
@@ -162,7 +162,7 @@ ngx_http_static_handler(ngx_http_request
                 len += r->args.len + 1;
             }
 
-            location = ngx_palloc(r->pool, len);
+            location = ngx_pnalloc(r->pool, len);
             if (location == NULL) {
                 return NGX_HTTP_INTERNAL_SERVER_ERROR;
             }
--- a/src/http/modules/ngx_http_sub_filter_module.c
+++ b/src/http/modules/ngx_http_sub_filter_module.c
@@ -710,7 +710,7 @@ ngx_http_sub_types(ngx_conf_t *cf, ngx_c
 
         type->len = value[i].len;
 
-        type->data = ngx_palloc(cf->pool, type->len + 1);
+        type->data = ngx_pnalloc(cf->pool, type->len + 1);
         if (type->data == NULL) {
             return NGX_CONF_ERROR;
         }
--- a/src/http/modules/ngx_http_userid_filter_module.c
+++ b/src/http/modules/ngx_http_userid_filter_module.c
@@ -420,7 +420,7 @@ ngx_http_userid_set_uid(ngx_http_request
         len += conf->domain.len;
     }
 
-    cookie = ngx_palloc(r->pool, len);
+    cookie = ngx_pnalloc(r->pool, len);
     if (cookie == NULL) {
         return NGX_ERROR;
     }
@@ -496,7 +496,7 @@ ngx_http_userid_variable(ngx_http_reques
     ngx_str_t *name, uint32_t *uid)
 {
     v->len = name->len + sizeof("=00001111222233334444555566667777") - 1;
-    v->data = ngx_palloc(r->pool, v->len);
+    v->data = ngx_pnalloc(r->pool, v->len);
     if (v->data == NULL) {
         return NGX_ERROR;
     }
@@ -620,7 +620,7 @@ ngx_http_userid_domain(ngx_conf_t *cf, v
         return NGX_CONF_OK;
     }
 
-    new = ngx_palloc(cf->pool, sizeof("; domain=") - 1 + domain->len);
+    new = ngx_pnalloc(cf->pool, sizeof("; domain=") - 1 + domain->len);
     if (new == NULL) {
         return NGX_CONF_ERROR;
     }
@@ -642,7 +642,7 @@ ngx_http_userid_path(ngx_conf_t *cf, voi
 
     u_char  *p, *new;
 
-    new = ngx_palloc(cf->pool, sizeof("; path=") - 1 + path->len);
+    new = ngx_pnalloc(cf->pool, sizeof("; path=") - 1 + path->len);
     if (new == NULL) {
         return NGX_CONF_ERROR;
     }
--- a/src/http/modules/perl/nginx.xs
+++ b/src/http/modules/perl/nginx.xs
@@ -48,7 +48,7 @@ ngx_http_perl_sv2str(pTHX_ ngx_http_requ
         return NGX_OK;
     }
 
-    s->data = ngx_palloc(r->pool, len);
+    s->data = ngx_pnalloc(r->pool, len);
     if (s->data == NULL) {
         return NGX_ERROR;
     }
@@ -242,7 +242,7 @@ header_in(r, key)
 
     /* look up hashed headers */
 
-    lowcase_key = ngx_palloc(r->pool, len);
+    lowcase_key = ngx_pnalloc(r->pool, len);
     if (lowcase_key == NULL) {
         XSRETURN_UNDEF;
     }
@@ -293,7 +293,7 @@ header_in(r, key)
             size += ph[i]->value.len + sizeof("; ") - 1;
         }
 
-        cookie = ngx_palloc(r->pool, size);
+        cookie = ngx_pnalloc(r->pool, size);
         if (cookie == NULL) {
             XSRETURN_UNDEF;
         }
@@ -769,7 +769,7 @@ unescape(r, text, type = 0)
 
     src = (u_char *) SvPV(text, len);
 
-    p = ngx_palloc(r->pool, len + 1);
+    p = ngx_pnalloc(r->pool, len + 1);
     if (p == NULL) {
         XSRETURN_UNDEF;
     }
@@ -826,7 +826,7 @@ variable(r, name, value = NULL)
 
     p = (u_char *) SvPV(name, len);
 
-    lowcase = ngx_palloc(r->pool, len);
+    lowcase = ngx_pnalloc(r->pool, len);
     if (lowcase == NULL) {
         XSRETURN_UNDEF;
     }
--- a/src/http/modules/perl/ngx_http_perl_module.c
+++ b/src/http/modules/perl/ngx_http_perl_module.c
@@ -703,7 +703,7 @@ ngx_http_perl_call_handler(pTHX_ ngx_htt
             line = SvPVx(POPs, n_a);
             rv->len = n_a;
 
-            rv->data = ngx_palloc(r->pool, n_a);
+            rv->data = ngx_pnalloc(r->pool, n_a);
             if (rv->data == NULL) {
                 return NGX_ERROR;
             }
--- a/src/http/ngx_http.c
+++ b/src/http/ngx_http.c
@@ -1024,8 +1024,8 @@ ngx_http_create_locations_tree(ngx_conf_
     lq = (ngx_http_location_queue_t *) q;
     len = lq->name->len - prefix;
 
-    node = ngx_palloc_aligned(cf->pool,
-                          offsetof(ngx_http_location_tree_node_t, name) + len);
+    node = ngx_palloc(cf->pool,
+                      offsetof(ngx_http_location_tree_node_t, name) + len);
     if (node == NULL) {
         return NULL;
     }
@@ -1615,7 +1615,7 @@ ngx_http_init_listening(ngx_conf_t *cf, 
 
         hip->port = in_port->port;
 
-        hip->port_text.data = ngx_palloc(cf->pool, 7);
+        hip->port_text.data = ngx_pnalloc(cf->pool, 7);
         if (hip->port_text.data == NULL) {
             return NGX_ERROR;
         }
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -832,7 +832,7 @@ ngx_http_core_find_config_phase(ngx_http
 
         } else {
             len = clcf->name.len + 1 + r->args.len;
-            p = ngx_palloc(r->pool, len);
+            p = ngx_pnalloc(r->pool, len);
 
             if (p == NULL) {
                 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
@@ -1267,7 +1267,7 @@ ngx_http_set_content_type(ngx_http_reque
 
             if (c >= 'A' && c <= 'Z') {
 
-                p = ngx_palloc(r->pool, r->exten.len);
+                p = ngx_pnalloc(r->pool, r->exten.len);
                 if (p == NULL) {
                     return NGX_HTTP_INTERNAL_SERVER_ERROR;
                 }
@@ -1390,7 +1390,7 @@ ngx_http_map_uri_to_path(ngx_http_reques
 
         path->len = clcf->root.len + reserved;
 
-        path->data = ngx_palloc(r->pool, path->len);
+        path->data = ngx_pnalloc(r->pool, path->len);
         if (path->data == NULL) {
             return NULL;
         }
@@ -1460,7 +1460,7 @@ ngx_http_auth_basic_user(ngx_http_reques
     }
 
     auth.len = ngx_base64_decoded_length(encoded.len);
-    auth.data = ngx_palloc(r->pool, auth.len + 1);
+    auth.data = ngx_pnalloc(r->pool, auth.len + 1);
     if (auth.data == NULL) {
         return NGX_ERROR;
     }
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -654,7 +654,7 @@ ngx_http_process_request_line(ngx_event_
 
             if (r->complex_uri || r->quoted_uri) {
 
-                r->uri.data = ngx_palloc(r->pool, r->uri.len + 1);
+                r->uri.data = ngx_pnalloc(r->pool, r->uri.len + 1);
                 if (r->uri.data == NULL) {
                     ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
                     return;
@@ -914,7 +914,7 @@ ngx_http_process_request_headers(ngx_eve
             h->value.data = r->header_start;
             h->value.data[h->value.len] = '\0';
 
-            h->lowcase_key = ngx_palloc(r->pool, h->key.len);
+            h->lowcase_key = ngx_pnalloc(r->pool, h->key.len);
             if (h->lowcase_key == NULL) {
                 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
                 return;
@@ -1562,7 +1562,7 @@ ngx_http_find_virtual_server(ngx_http_re
         server = buf;
 
     } else {
-        server = ngx_palloc(r->pool, len);
+        server = ngx_pnalloc(r->pool, len);
         if (server == NULL) {
             return NGX_ERROR;
         }
--- a/src/http/ngx_http_script.c
+++ b/src/http/ngx_http_script.c
@@ -341,7 +341,7 @@ ngx_http_script_run(ngx_http_request_t *
 
 
     value->len = len;
-    value->data = ngx_palloc(r->pool, len);
+    value->data = ngx_pnalloc(r->pool, len);
     if (value->data == NULL) {
         return NULL;
     }
@@ -733,7 +733,7 @@ ngx_http_script_regex_start_code(ngx_htt
         e->buf.len += r->args.len + 1;
     }
 
-    e->buf.data = ngx_palloc(r->pool, e->buf.len);
+    e->buf.data = ngx_pnalloc(r->pool, e->buf.len);
     if (e->buf.data == NULL) {
         e->ip = ngx_http_script_exit;
         e->status = NGX_HTTP_INTERNAL_SERVER_ERROR;
@@ -1120,7 +1120,7 @@ ngx_http_script_complex_value_code(ngx_h
     }
 
     e->buf.len = len;
-    e->buf.data = ngx_palloc(e->request->pool, len);
+    e->buf.data = ngx_pnalloc(e->request->pool, len);
     if (e->buf.data == NULL) {
         e->ip = ngx_http_script_exit;
         e->status = NGX_HTTP_INTERNAL_SERVER_ERROR;
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -2817,7 +2817,7 @@ ngx_http_upstream_addr_variable(ngx_http
         }
     }
 
-    p = ngx_palloc(r->pool, len);
+    p = ngx_pnalloc(r->pool, len);
     if (p == NULL) {
         return NGX_ERROR;
     }
@@ -2878,7 +2878,7 @@ ngx_http_upstream_status_variable(ngx_ht
 
     len = r->upstream_states->nelts * (3 + 2);
 
-    p = ngx_palloc(r->pool, len);
+    p = ngx_pnalloc(r->pool, len);
     if (p == NULL) {
         return NGX_ERROR;
     }
@@ -2944,7 +2944,7 @@ ngx_http_upstream_response_time_variable
 
     len = r->upstream_states->nelts * (NGX_TIME_T_LEN + 4 + 2);
 
-    p = ngx_palloc(r->pool, len);
+    p = ngx_pnalloc(r->pool, len);
     if (p == NULL) {
         return NGX_ERROR;
     }
--- a/src/http/ngx_http_upstream_round_robin.c
+++ b/src/http/ngx_http_upstream_round_robin.c
@@ -283,7 +283,7 @@ ngx_http_upstream_create_round_robin_pee
 
         len = INET_ADDRSTRLEN - 1 + 1 + sizeof(":65536") - 1;
 
-        p = ngx_palloc(r->pool, len);
+        p = ngx_pnalloc(r->pool, len);
         if (p == NULL) {
             return NGX_ERROR;
         }
--- a/src/http/ngx_http_variables.c
+++ b/src/http/ngx_http_variables.c
@@ -272,7 +272,7 @@ ngx_http_add_variable(ngx_conf_t *cf, ng
     }
 
     v->name.len = name->len;
-    v->name.data = ngx_palloc(cf->pool, name->len);
+    v->name.data = ngx_pnalloc(cf->pool, name->len);
     if (v->name.data == NULL) {
         return NULL;
     }
@@ -339,7 +339,7 @@ ngx_http_get_variable_index(ngx_conf_t *
     }
 
     v->name.len = name->len;
-    v->name.data = ngx_palloc(cf->pool, name->len);
+    v->name.data = ngx_pnalloc(cf->pool, name->len);
     if (v->name.data == NULL) {
         return NGX_ERROR;
     }
@@ -615,7 +615,7 @@ ngx_http_variable_headers(ngx_http_reque
         len += h[i]->value.len + sizeof("; ") - 1;
     }
 
-    p = ngx_palloc(r->pool, len);
+    p = ngx_pnalloc(r->pool, len);
     if (p == NULL) {
         return NGX_ERROR;
     }
@@ -782,7 +782,7 @@ ngx_http_variable_remote_port(ngx_http_r
     v->no_cacheable = 0;
     v->not_found = 0;
 
-    v->data = ngx_palloc(r->pool, sizeof("65535") - 1);
+    v->data = ngx_pnalloc(r->pool, sizeof("65535") - 1);
     if (v->data == NULL) {
         return NGX_ERROR;
     }
@@ -809,7 +809,7 @@ ngx_http_variable_server_addr(ngx_http_r
 {
     ngx_str_t  s;
 
-    s.data = ngx_palloc(r->pool, INET_ADDRSTRLEN);
+    s.data = ngx_pnalloc(r->pool, INET_ADDRSTRLEN);
     if (s.data == NULL) {
         return NGX_ERROR;
     }
@@ -1032,7 +1032,7 @@ ngx_http_variable_body_bytes_sent(ngx_ht
         sent = 0;
     }
 
-    p = ngx_palloc(r->pool, NGX_OFF_T_LEN);
+    p = ngx_pnalloc(r->pool, NGX_OFF_T_LEN);
     if (p == NULL) {
         return NGX_ERROR;
     }
@@ -1083,7 +1083,7 @@ ngx_http_variable_sent_content_length(ng
     }
 
     if (r->headers_out.content_length_n >= 0) {
-        p = ngx_palloc(r->pool, NGX_OFF_T_LEN);
+        p = ngx_pnalloc(r->pool, NGX_OFF_T_LEN);
         if (p == NULL) {
             return NGX_ERROR;
         }
@@ -1120,7 +1120,7 @@ ngx_http_variable_sent_last_modified(ngx
     }
 
     if (r->headers_out.last_modified_time >= 0) {
-        p = ngx_palloc(r->pool,
+        p = ngx_pnalloc(r->pool,
                    sizeof("Last-Modified: Mon, 28 Sep 1970 06:00:00 GMT") - 1);
         if (p == NULL) {
             return NGX_ERROR;
@@ -1179,7 +1179,7 @@ ngx_http_variable_sent_keep_alive(ngx_ht
 
         if (clcf->keepalive_header) {
 
-            p = ngx_palloc(r->pool, sizeof("timeout=") - 1 + NGX_TIME_T_LEN);
+            p = ngx_pnalloc(r->pool, sizeof("timeout=") - 1 + NGX_TIME_T_LEN);
             if (p == NULL) {
                 return NGX_ERROR;
             }
--- a/src/mail/ngx_mail.c
+++ b/src/mail/ngx_mail.c
@@ -357,8 +357,8 @@ ngx_mail_block(ngx_conf_t *cf, ngx_comma
                 imip->addrs[i].addr = in_addr[i].addr;
                 imip->addrs[i].ctx = in_addr[i].ctx;
 
-                text = ngx_palloc(cf->pool,
-                                  INET_ADDRSTRLEN - 1 + sizeof(":65535") - 1);
+                text = ngx_pnalloc(cf->pool,
+                                   INET_ADDRSTRLEN - 1 + sizeof(":65535") - 1);
                 if (text == NULL) {
                     return NGX_CONF_ERROR;
                 }
--- a/src/mail/ngx_mail_auth_http_module.c
+++ b/src/mail/ngx_mail_auth_http_module.c
@@ -593,7 +593,7 @@ ngx_mail_auth_http_process_headers(ngx_m
             {
                 s->login.len = ctx->header_end - ctx->header_start;
 
-                s->login.data = ngx_palloc(s->connection->pool, s->login.len);
+                s->login.data = ngx_pnalloc(s->connection->pool, s->login.len);
                 if (s->login.data == NULL) {
                     ngx_close_connection(ctx->peer.connection);
                     ngx_destroy_pool(ctx->pool);
@@ -614,7 +614,8 @@ ngx_mail_auth_http_process_headers(ngx_m
             {
                 s->passwd.len = ctx->header_end - ctx->header_start;
 
-                s->passwd.data = ngx_palloc(s->connection->pool, s->passwd.len);
+                s->passwd.data = ngx_pnalloc(s->connection->pool,
+                                             s->passwd.len);
                 if (s->passwd.data == NULL) {
                     ngx_close_connection(ctx->peer.connection);
                     ngx_destroy_pool(ctx->pool);
@@ -651,8 +652,8 @@ ngx_mail_auth_http_process_headers(ngx_m
             {
                 ctx->errcode.len = ctx->header_end - ctx->header_start;
 
-                ctx->errcode.data = ngx_palloc(s->connection->pool,
-                                               ctx->errcode.len);
+                ctx->errcode.data = ngx_pnalloc(s->connection->pool,
+                                                ctx->errcode.len);
                 if (ctx->errcode.data == NULL) {
                     ngx_close_connection(ctx->peer.connection);
                     ngx_destroy_pool(ctx->pool);
@@ -691,7 +692,7 @@ ngx_mail_auth_http_process_headers(ngx_m
                     ctx->err.len = ctx->errcode.len + ctx->errmsg.len
                                    + sizeof(" " CRLF) - 1;
 
-                    p = ngx_palloc(s->connection->pool, ctx->err.len);
+                    p = ngx_pnalloc(s->connection->pool, ctx->err.len);
                     if (p == NULL) {
                         ngx_close_connection(ctx->peer.connection);
                         ngx_destroy_pool(ctx->pool);
@@ -810,7 +811,7 @@ ngx_mail_auth_http_process_headers(ngx_m
 
             peer->name.len = len;
 
-            peer->name.data = ngx_palloc(s->connection->pool, len);
+            peer->name.data = ngx_pnalloc(s->connection->pool, len);
             if (peer->name.data == NULL) {
                 ngx_destroy_pool(ctx->pool);
                 ngx_mail_session_internal_server_error(s);
@@ -1255,7 +1256,7 @@ ngx_mail_auth_http_escape(ngx_pool_t *po
 
     escaped->len = text->len + n * 2;
 
-    p = ngx_palloc(pool, escaped->len);
+    p = ngx_pnalloc(pool, escaped->len);
     if (p == NULL) {
         return NGX_ERROR;
     }
@@ -1326,7 +1327,7 @@ ngx_mail_auth_http_merge_conf(ngx_conf_t
             len += header[i].key.len + 2 + header[i].value.len + 2;
         }
 
-        p = ngx_palloc(cf->pool, len);
+        p = ngx_pnalloc(cf->pool, len);
         if (p == NULL) {
             return NGX_CONF_ERROR;
         }
--- a/src/mail/ngx_mail_handler.c
+++ b/src/mail/ngx_mail_handler.c
@@ -236,10 +236,10 @@ ngx_int_t
 ngx_mail_salt(ngx_mail_session_t *s, ngx_connection_t *c,
     ngx_mail_core_srv_conf_t *cscf)
 {
-    s->salt.data = ngx_palloc(c->pool,
-                              sizeof(" <18446744073709551616.@>" CRLF) - 1
-                              + NGX_TIME_T_LEN
-                              + cscf->server_name.len);
+    s->salt.data = ngx_pnalloc(c->pool,
+                               sizeof(" <18446744073709551616.@>" CRLF) - 1
+                               + NGX_TIME_T_LEN
+                               + cscf->server_name.len);
     if (s->salt.data == NULL) {
         return NGX_ERROR;
     }
@@ -288,7 +288,7 @@ ngx_mail_auth_plain(ngx_mail_session_t *
                    "mail auth plain: \"%V\"", &arg[n]);
 #endif
 
-    plain.data = ngx_palloc(c->pool, ngx_base64_decoded_length(arg[n].len));
+    plain.data = ngx_pnalloc(c->pool, ngx_base64_decoded_length(arg[n].len));
     if (plain.data == NULL){
         return NGX_ERROR;
     }
@@ -344,7 +344,7 @@ ngx_mail_auth_login_username(ngx_mail_se
     ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0,
                    "mail auth login username: \"%V\"", &arg[0]);
 
-    s->login.data = ngx_palloc(c->pool, ngx_base64_decoded_length(arg[0].len));
+    s->login.data = ngx_pnalloc(c->pool, ngx_base64_decoded_length(arg[0].len));
     if (s->login.data == NULL){
         return NGX_ERROR;
     }
@@ -374,7 +374,8 @@ ngx_mail_auth_login_password(ngx_mail_se
                    "mail auth login password: \"%V\"", &arg[0]);
 #endif
 
-    s->passwd.data = ngx_palloc(c->pool, ngx_base64_decoded_length(arg[0].len));
+    s->passwd.data = ngx_pnalloc(c->pool,
+                                 ngx_base64_decoded_length(arg[0].len));
     if (s->passwd.data == NULL){
         return NGX_ERROR;
     }
@@ -402,7 +403,7 @@ ngx_mail_auth_cram_md5_salt(ngx_mail_ses
     ngx_str_t    salt;
     ngx_uint_t   n;
 
-    p = ngx_palloc(c->pool, len + ngx_base64_encoded_length(s->salt.len) + 2);
+    p = ngx_pnalloc(c->pool, len + ngx_base64_encoded_length(s->salt.len) + 2);
     if (p == NULL) {
         return NGX_ERROR;
     }
@@ -434,7 +435,7 @@ ngx_mail_auth_cram_md5(ngx_mail_session_
     ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0,
                    "mail auth cram-md5: \"%V\"", &arg[0]);
 
-    s->login.data = ngx_palloc(c->pool, ngx_base64_decoded_length(arg[0].len));
+    s->login.data = ngx_pnalloc(c->pool, ngx_base64_decoded_length(arg[0].len));
     if (s->login.data == NULL){
         return NGX_ERROR;
     }
--- a/src/mail/ngx_mail_imap_handler.c
+++ b/src/mail/ngx_mail_imap_handler.c
@@ -259,7 +259,7 @@ ngx_mail_imap_auth_state(ngx_event_t *re
 
         if (s->tagged_line.len < s->tag.len + s->text.len + s->out.len) {
             s->tagged_line.len = s->tag.len + s->text.len + s->out.len;
-            s->tagged_line.data = ngx_palloc(c->pool, s->tagged_line.len);
+            s->tagged_line.data = ngx_pnalloc(c->pool, s->tagged_line.len);
             if (s->tagged_line.data == NULL) {
                 ngx_mail_close_connection(c);
                 return;
@@ -317,7 +317,7 @@ ngx_mail_imap_login(ngx_mail_session_t *
     }
 
     s->login.len = arg[0].len;
-    s->login.data = ngx_palloc(c->pool, s->login.len);
+    s->login.data = ngx_pnalloc(c->pool, s->login.len);
     if (s->login.data == NULL) {
         return NGX_ERROR;
     }
@@ -325,7 +325,7 @@ ngx_mail_imap_login(ngx_mail_session_t *
     ngx_memcpy(s->login.data, arg[0].data, s->login.len);
 
     s->passwd.len = arg[1].len;
-    s->passwd.data = ngx_palloc(c->pool, s->passwd.len);
+    s->passwd.data = ngx_pnalloc(c->pool, s->passwd.len);
     if (s->passwd.data == NULL) {
         return NGX_ERROR;
     }
--- a/src/mail/ngx_mail_imap_module.c
+++ b/src/mail/ngx_mail_imap_module.c
@@ -183,7 +183,7 @@ ngx_mail_imap_merge_srv_conf(ngx_conf_t 
         }
     }
 
-    p = ngx_palloc(cf->pool, size);
+    p = ngx_pnalloc(cf->pool, size);
     if (p == NULL) {
         return NGX_CONF_ERROR;
     }
@@ -216,7 +216,7 @@ ngx_mail_imap_merge_srv_conf(ngx_conf_t 
 
     size += sizeof(" STARTTLS") - 1;
 
-    p = ngx_palloc(cf->pool, size);
+    p = ngx_pnalloc(cf->pool, size);
     if (p == NULL) {
         return NGX_CONF_ERROR;
     }
@@ -233,7 +233,7 @@ ngx_mail_imap_merge_srv_conf(ngx_conf_t 
     size = (auth - conf->capability.data) + sizeof(CRLF) - 1
             + sizeof(" STARTTLS LOGINDISABLED") - 1;
 
-    p = ngx_palloc(cf->pool, size);
+    p = ngx_pnalloc(cf->pool, size);
     if (p == NULL) {
         return NGX_CONF_ERROR;
     }
--- a/src/mail/ngx_mail_pop3_handler.c
+++ b/src/mail/ngx_mail_pop3_handler.c
@@ -46,7 +46,7 @@ ngx_mail_pop3_init_session(ngx_mail_sess
             return;
         }
 
-        s->out.data = ngx_palloc(c->pool, sizeof(pop3_greeting) + s->salt.len);
+        s->out.data = ngx_pnalloc(c->pool, sizeof(pop3_greeting) + s->salt.len);
         if (s->out.data == NULL) {
             ngx_mail_session_internal_server_error(s);
             return;
@@ -297,7 +297,7 @@ ngx_mail_pop3_user(ngx_mail_session_t *s
 
     arg = s->args.elts;
     s->login.len = arg[0].len;
-    s->login.data = ngx_palloc(c->pool, s->login.len);
+    s->login.data = ngx_pnalloc(c->pool, s->login.len);
     if (s->login.data == NULL) {
         return NGX_ERROR;
     }
@@ -324,7 +324,7 @@ ngx_mail_pop3_pass(ngx_mail_session_t *s
 
     arg = s->args.elts;
     s->passwd.len = arg[0].len;
-    s->passwd.data = ngx_palloc(c->pool, s->passwd.len);
+    s->passwd.data = ngx_pnalloc(c->pool, s->passwd.len);
     if (s->passwd.data == NULL) {
         return NGX_ERROR;
     }
@@ -417,7 +417,7 @@ ngx_mail_pop3_apop(ngx_mail_session_t *s
     arg = s->args.elts;
 
     s->login.len = arg[0].len;
-    s->login.data = ngx_palloc(c->pool, s->login.len);
+    s->login.data = ngx_pnalloc(c->pool, s->login.len);
     if (s->login.data == NULL) {
         return NGX_ERROR;
     }
@@ -425,7 +425,7 @@ ngx_mail_pop3_apop(ngx_mail_session_t *s
     ngx_memcpy(s->login.data, arg[0].data, s->login.len);
 
     s->passwd.len = arg[1].len;
-    s->passwd.data = ngx_palloc(c->pool, s->passwd.len);
+    s->passwd.data = ngx_pnalloc(c->pool, s->passwd.len);
     if (s->passwd.data == NULL) {
         return NGX_ERROR;
     }
--- a/src/mail/ngx_mail_pop3_module.c
+++ b/src/mail/ngx_mail_pop3_module.c
@@ -183,7 +183,7 @@ ngx_mail_pop3_merge_srv_conf(ngx_conf_t 
         size += sizeof("SASL LOGIN PLAIN" CRLF) - 1;
     }
 
-    p = ngx_palloc(cf->pool, size);
+    p = ngx_pnalloc(cf->pool, size);
     if (p == NULL) {
         return NGX_CONF_ERROR;
     }
@@ -213,7 +213,7 @@ ngx_mail_pop3_merge_srv_conf(ngx_conf_t 
 
     size += sizeof("STLS" CRLF) - 1;
 
-    p = ngx_palloc(cf->pool, size);
+    p = ngx_pnalloc(cf->pool, size);
     if (p == NULL) {
         return NGX_CONF_ERROR;
     }
@@ -236,7 +236,7 @@ ngx_mail_pop3_merge_srv_conf(ngx_conf_t 
     }
 
 
-    p = ngx_palloc(cf->pool, stls_only_size);
+    p = ngx_pnalloc(cf->pool, stls_only_size);
     if (p == NULL) {
         return NGX_CONF_ERROR;
     }
--- a/src/mail/ngx_mail_proxy_module.c
+++ b/src/mail/ngx_mail_proxy_module.c
@@ -253,7 +253,7 @@ ngx_mail_proxy_pop3_handler(ngx_event_t 
         s->connection->log->action = "sending user name to upstream";
 
         line.len = sizeof("USER ")  - 1 + s->login.len + 2;
-        line.data = ngx_palloc(c->pool, line.len);
+        line.data = ngx_pnalloc(c->pool, line.len);
         if (line.data == NULL) {
             ngx_mail_proxy_internal_server_error(s);
             return;
@@ -272,7 +272,7 @@ ngx_mail_proxy_pop3_handler(ngx_event_t 
         s->connection->log->action = "sending password to upstream";
 
         line.len = sizeof("PASS ")  - 1 + s->passwd.len + 2;
-        line.data = ngx_palloc(c->pool, line.len);
+        line.data = ngx_pnalloc(c->pool, line.len);
         if (line.data == NULL) {
             ngx_mail_proxy_internal_server_error(s);
             return;
@@ -369,7 +369,7 @@ ngx_mail_proxy_imap_handler(ngx_event_t 
 
         line.len = s->tag.len + sizeof("LOGIN ") - 1
                    + 1 + NGX_SIZE_T_LEN + 1 + 2;
-        line.data = ngx_palloc(c->pool, line.len);
+        line.data = ngx_pnalloc(c->pool, line.len);
         if (line.data == NULL) {
             ngx_mail_proxy_internal_server_error(s);
             return;
@@ -388,7 +388,7 @@ ngx_mail_proxy_imap_handler(ngx_event_t 
         s->connection->log->action = "sending user name to upstream";
 
         line.len = s->login.len + 1 + 1 + NGX_SIZE_T_LEN + 1 + 2;
-        line.data = ngx_palloc(c->pool, line.len);
+        line.data = ngx_pnalloc(c->pool, line.len);
         if (line.data == NULL) {
             ngx_mail_proxy_internal_server_error(s);
             return;
@@ -408,7 +408,7 @@ ngx_mail_proxy_imap_handler(ngx_event_t 
         s->connection->log->action = "sending password to upstream";
 
         line.len = s->passwd.len + 2;
-        line.data = ngx_palloc(c->pool, line.len);
+        line.data = ngx_pnalloc(c->pool, line.len);
         if (line.data == NULL) {
             ngx_mail_proxy_internal_server_error(s);
             return;
@@ -505,7 +505,7 @@ ngx_mail_proxy_smtp_handler(ngx_event_t 
         cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module);
 
         line.len = sizeof("HELO ")  - 1 + cscf->server_name.len + 2;
-        line.data = ngx_palloc(c->pool, line.len);
+        line.data = ngx_pnalloc(c->pool, line.len);
         if (line.data == NULL) {
             ngx_mail_proxy_internal_server_error(s);
             return;
@@ -535,7 +535,7 @@ ngx_mail_proxy_smtp_handler(ngx_event_t 
                    + s->esmtp + s->smtp_helo.len
                    + s->connection->addr_text.len + s->login.len + s->host.len;
 
-        line.data = ngx_palloc(c->pool, line.len);
+        line.data = ngx_pnalloc(c->pool, line.len);
         if (line.data == NULL) {
             ngx_mail_proxy_internal_server_error(s);
             return;
--- a/src/mail/ngx_mail_smtp_handler.c
+++ b/src/mail/ngx_mail_smtp_handler.c
@@ -506,7 +506,7 @@ ngx_mail_smtp_helo(ngx_mail_session_t *s
 
     s->smtp_helo.len = arg[0].len;
 
-    s->smtp_helo.data = ngx_palloc(c->pool, arg[0].len);
+    s->smtp_helo.data = ngx_pnalloc(c->pool, arg[0].len);
     if (s->smtp_helo.data == NULL) {
         return NGX_ERROR;
     }
--- a/src/mail/ngx_mail_smtp_module.c
+++ b/src/mail/ngx_mail_smtp_module.c
@@ -160,7 +160,7 @@ ngx_mail_smtp_merge_srv_conf(ngx_conf_t 
 
     size = sizeof("220  ESMTP ready" CRLF) - 1 + cscf->server_name.len;
 
-    p = ngx_palloc(cf->pool, size);
+    p = ngx_pnalloc(cf->pool, size);
     if (p == NULL) {
         return NGX_CONF_ERROR;
     }
@@ -175,7 +175,7 @@ ngx_mail_smtp_merge_srv_conf(ngx_conf_t 
 
     size = sizeof("250 " CRLF) - 1 + cscf->server_name.len;
 
-    p = ngx_palloc(cf->pool, size);
+    p = ngx_pnalloc(cf->pool, size);
     if (p == NULL) {
         return NGX_CONF_ERROR;
     }
@@ -209,7 +209,7 @@ ngx_mail_smtp_merge_srv_conf(ngx_conf_t 
         }
     }
 
-    p = ngx_palloc(cf->pool, size);
+    p = ngx_pnalloc(cf->pool, size);
     if (p == NULL) {
         return NGX_CONF_ERROR;
     }
@@ -247,7 +247,7 @@ ngx_mail_smtp_merge_srv_conf(ngx_conf_t 
 
     size += sizeof("250 STARTTLS" CRLF) - 1;
 
-    p = ngx_palloc(cf->pool, size);
+    p = ngx_pnalloc(cf->pool, size);
     if (p == NULL) {
         return NGX_CONF_ERROR;
     }
@@ -268,7 +268,7 @@ ngx_mail_smtp_merge_srv_conf(ngx_conf_t 
     size = (auth - conf->capability.data)
             + sizeof("250 STARTTLS" CRLF) - 1;
 
-    p = ngx_palloc(cf->pool, size);
+    p = ngx_pnalloc(cf->pool, size);
     if (p == NULL) {
         return NGX_CONF_ERROR;
     }
--- a/src/mysql/ngx_http_mysql_test.c
+++ b/src/mysql/ngx_http_mysql_test.c
@@ -129,7 +129,7 @@ ngx_http_mysql_auth(ngx_mysql_t *m)
 
     m->query.len = NGX_MYSQL_CMDPKT_LEN + ngx_mysql_command_query.len;
 
-    m->query.data = ngx_palloc(r->pool, m->query.len);
+    m->query.data = ngx_pnalloc(r->pool, m->query.len);
     if (m->query.data == NULL) {
         ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
         return;
--- a/src/mysql/ngx_mysql.c
+++ b/src/mysql/ngx_mysql.c
@@ -215,7 +215,7 @@ ngx_mysql_read_server_greeting(ngx_event
         len += 20;
     }
 
-    auth = ngx_palloc(m->pool, len);
+    auth = ngx_pnalloc(m->pool, len);
     if (auth == NULL) {
         ngx_mysql_close(m, NGX_ERROR);
         return;
--- a/src/os/unix/ngx_process_cycle.c
+++ b/src/os/unix/ngx_process_cycle.c
@@ -108,7 +108,7 @@ ngx_master_process_cycle(ngx_cycle_t *cy
         size += ngx_strlen(ngx_argv[i]) + 1;
     }
 
-    title = ngx_palloc(cycle->pool, size);
+    title = ngx_pnalloc(cycle->pool, size);
 
     p = ngx_cpymem(title, master_process, sizeof(master_process) - 1);
     for (i = 0; i < ngx_argc; i++) {
--- a/src/os/unix/ngx_user.c
+++ b/src/os/unix/ngx_user.c
@@ -43,7 +43,7 @@ ngx_crypt(ngx_pool_t *pool, u_char *key,
     if (err == 0) {
         len = ngx_strlen(value);
 
-        *encrypted = ngx_palloc(pool, len);
+        *encrypted = ngx_pnalloc(pool, len);
         if (*encrypted) {
             ngx_memcpy(*encrypted, value, len + 1);
             return NGX_OK;
@@ -81,7 +81,7 @@ ngx_crypt(ngx_pool_t *pool, u_char *key,
     if (value) {
         len = ngx_strlen(value);
 
-        *encrypted = ngx_palloc(pool, len);
+        *encrypted = ngx_pnalloc(pool, len);
         if (*encrypted) {
             ngx_memcpy(*encrypted, value, len + 1);
         }