# HG changeset patch # User Igor Sysoev # Date 1179755375 0 # Node ID 103988cef75767925fccb9bc9848257e426688b2 # Parent 451e34738078de0e256b0017ea2776a087ca5634 use memory optimization for i386 and amd64 only: this fixes SIGBUS in PCRE on sparc64 diff --git a/src/core/ngx_palloc.c b/src/core/ngx_palloc.c --- a/src/core/ngx_palloc.c +++ b/src/core/ngx_palloc.c @@ -97,10 +97,21 @@ ngx_palloc(ngx_pool_t *pool, size_t size 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 + * size) + */ + if (size < sizeof(int) || (size & 1)) { m = p->last; - } else { + } else +#endif + + { m = ngx_align_ptr(p->last, NGX_ALIGNMENT); }