Linux/SPARC malloc() returns an address aligned to 8. This conflicts with

our SPARC 16-byte alignment and some allocations may be done out of pool.
ngx_memalign(ngx_pagesize) fixes this issue.
This commit is contained in:
Igor Sysoev 2009-09-30 12:56:44 +00:00
parent 689064b91a
commit 687b0e99ea
2 changed files with 6 additions and 3 deletions

View File

@ -280,6 +280,9 @@ main(int argc, char *const *argv)
init_cycle.log = log;
ngx_cycle = &init_cycle;
/* dummy pagesize to create aligned pool */
ngx_pagesize = 1024;
init_cycle.pool = ngx_create_pool(1024, log);
if (init_cycle.pool == NULL) {
return 1;

View File

@ -17,7 +17,7 @@ ngx_create_pool(size_t size, ngx_log_t *log)
{
ngx_pool_t *p;
p = ngx_alloc(size, log);
p = ngx_memalign(ngx_pagesize, size, log);
if (p == NULL) {
return NULL;
}
@ -181,7 +181,7 @@ ngx_palloc_block(ngx_pool_t *pool, size_t size)
psize = (size_t) (pool->d.end - (u_char *) pool);
m = ngx_alloc(psize, pool->log);
m = ngx_memalign(ngx_pagesize, psize, pool->log);
if (m == NULL) {
return NULL;
}
@ -219,7 +219,7 @@ ngx_palloc_large(ngx_pool_t *pool, size_t size)
ngx_uint_t n;
ngx_pool_large_t *large;
p = ngx_alloc(size, pool->log);
p = ngx_memalign(ngx_pagesize, size, pool->log);
if (p == NULL) {
return NULL;
}