diff options
author | Mladen Turk <mturk@apache.org> | 2009-03-09 09:10:25 +0000 |
---|---|---|
committer | Mladen Turk <mturk@apache.org> | 2009-03-09 09:10:25 +0000 |
commit | a7b76dc551e513a0f8bc62b2792d0065c0c5538d (patch) | |
tree | b6280b618c7480226ed0d6d96b0c951ec702aaa8 /memory | |
parent | 62a1530bbe5d962551e09bc4bd0ed3db7783974f (diff) | |
download | apr-a7b76dc551e513a0f8bc62b2792d0065c0c5538d.tar.gz |
When creating allocator together with unmanaged pool
use a single memory block for allocator and first memnode, instead calling malloc twice
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@751627 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'memory')
-rw-r--r-- | memory/unix/apr_pools.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/memory/unix/apr_pools.c b/memory/unix/apr_pools.c index 017dc8781..1b1cd6463 100644 --- a/memory/unix/apr_pools.c +++ b/memory/unix/apr_pools.c @@ -929,7 +929,7 @@ APR_DECLARE(apr_status_t) apr_pool_create_unmanaged_ex(apr_pool_t **newpool, if (!apr_pools_initialized) return APR_ENOPOOL; if ((pool_allocator = allocator) == NULL) { - if ((pool_allocator = malloc(SIZEOF_ALLOCATOR_T)) == NULL) { + if ((pool_allocator = malloc(MIN_ALLOC + SIZEOF_ALLOCATOR_T)) == NULL) { if (abort_fn) abort_fn(APR_ENOMEM); @@ -937,9 +937,14 @@ APR_DECLARE(apr_status_t) apr_pool_create_unmanaged_ex(apr_pool_t **newpool, } memset(pool_allocator, 0, SIZEOF_ALLOCATOR_T); pool_allocator->max_free_index = APR_ALLOCATOR_MAX_FREE_UNLIMITED; - } - if ((node = allocator_alloc(pool_allocator, - MIN_ALLOC - APR_MEMNODE_T_SIZE)) == NULL) { + node = (apr_memnode_t *)((char *)pool_allocator + SIZEOF_ALLOCATOR_T); + node->next = NULL; + node->index = 1; + node->first_avail = (char *)node + APR_MEMNODE_T_SIZE; + node->endp = (char *)node + MIN_ALLOC; + } + else if ((node = allocator_alloc(pool_allocator, + MIN_ALLOC - APR_MEMNODE_T_SIZE)) == NULL) { if (abort_fn) abort_fn(APR_ENOMEM); |