Mercurial > hg > nginx-quic
diff src/core/ngx_palloc.c @ 2039:4d8140271204
*) 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()
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 27 May 2008 09:37:40 +0000 |
parents | d65172100f6b |
children | 2a92804f4109 |
line wrap: on
line diff
--- a/src/core/ngx_palloc.c +++ b/src/core/ngx_palloc.c @@ -99,8 +99,6 @@ 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 @@ -110,10 +108,7 @@ ngx_palloc(ngx_pool_t *pool, size_t size if (size < sizeof(int) || (size & 1)) { m = p->last; - } else -#endif - - { + } else { m = ngx_align_ptr(p->last, NGX_ALIGNMENT); } @@ -177,6 +172,17 @@ 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) {