*) add ngx_palloc_aligned() to allocate explicitlty aligned memory
*) allows non-aligned memory blocks for small allocations and for odd
   length strings on all platforms
*) use ngx_palloc_aligned()
diff --git a/src/core/ngx_palloc.c b/src/core/ngx_palloc.c
index 4cf7e8a..130c670 100644
--- a/src/core/ngx_palloc.c
+++ b/src/core/ngx_palloc.c
@@ -99,8 +99,6 @@
 
         for ( ;; ) {
 
-#if (NGX_HAVE_NONALIGNED)
-
             /*
              * allow non-aligned memory blocks for small allocations (1, 2,
              * or 3 bytes) and for odd length strings (struct's have aligned
@@ -110,10 +108,7 @@
             if (size < sizeof(int) || (size & 1)) {
                 m = p->last;
 
-            } else
-#endif
-
-            {
+            } else {
                 m = ngx_align_ptr(p->last, NGX_ALIGNMENT);
             }
 
@@ -177,6 +172,17 @@
 }
 
 
+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)
 {
diff --git a/src/core/ngx_palloc.h b/src/core/ngx_palloc.h
index 13443d7..11e2b41 100644
--- a/src/core/ngx_palloc.h
+++ b/src/core/ngx_palloc.h
@@ -69,6 +69,7 @@
 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_pcalloc(ngx_pool_t *pool, size_t size);
 ngx_int_t ngx_pfree(ngx_pool_t *pool, void *p);
 
diff --git a/src/core/ngx_regex.c b/src/core/ngx_regex.c
index be2dae7..fb12ab1 100644
--- a/src/core/ngx_regex.c
+++ b/src/core/ngx_regex.c
@@ -165,7 +165,7 @@
 #endif
 
     if (pool) {
-        return ngx_palloc(pool, size);
+        return ngx_palloc_aligned(pool, size);
     }
 
     return NULL;
diff --git a/src/http/ngx_http.c b/src/http/ngx_http.c
index a1c4c98..e8e059c 100644
--- a/src/http/ngx_http.c
+++ b/src/http/ngx_http.c
@@ -1024,12 +1024,15 @@
     lq = (ngx_http_location_queue_t *) q;
     len = lq->name->len - prefix;
 
-    node = ngx_pcalloc(cf->pool,
-                       offsetof(ngx_http_location_tree_node_t, name) + len);
+    node = ngx_palloc_aligned(cf->pool,
+                          offsetof(ngx_http_location_tree_node_t, name) + len);
     if (node == NULL) {
         return NULL;
     }
 
+    node->left = NULL;
+    node->right = NULL;
+    node->tree = NULL;
     node->exact = lq->exact;
     node->inclusive = lq->inclusive;