You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by mt...@apache.org on 2009/03/09 10:10:25 UTC
svn commit: r751627 - /apr/apr/trunk/memory/unix/apr_pools.c
Author: mturk
Date: Mon Mar 9 09:10:25 2009
New Revision: 751627
URL: http://svn.apache.org/viewvc?rev=751627&view=rev
Log:
When creating allocator together with unmanaged pool
use a single memory block for allocator and first memnode, instead calling malloc twice
Modified:
apr/apr/trunk/memory/unix/apr_pools.c
Modified: apr/apr/trunk/memory/unix/apr_pools.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/memory/unix/apr_pools.c?rev=751627&r1=751626&r2=751627&view=diff
==============================================================================
--- apr/apr/trunk/memory/unix/apr_pools.c (original)
+++ apr/apr/trunk/memory/unix/apr_pools.c Mon Mar 9 09:10:25 2009
@@ -929,7 +929,7 @@
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 @@
}
memset(pool_allocator, 0, SIZEOF_ALLOCATOR_T);
pool_allocator->max_free_index = APR_ALLOCATOR_MAX_FREE_UNLIMITED;
+ 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;
}
- if ((node = allocator_alloc(pool_allocator,
- MIN_ALLOC - APR_MEMNODE_T_SIZE)) == NULL) {
+ else if ((node = allocator_alloc(pool_allocator,
+ MIN_ALLOC - APR_MEMNODE_T_SIZE)) == NULL) {
if (abort_fn)
abort_fn(APR_ENOMEM);