Return-Path: Delivered-To: apmail-apr-commits-archive@www.apache.org Received: (qmail 42500 invoked from network); 16 Apr 2008 05:39:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Apr 2008 05:39:08 -0000 Received: (qmail 72580 invoked by uid 500); 16 Apr 2008 05:39:09 -0000 Delivered-To: apmail-apr-commits-archive@apr.apache.org Received: (qmail 72535 invoked by uid 500); 16 Apr 2008 05:39:08 -0000 Mailing-List: contact commits-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: Reply-To: dev@apr.apache.org List-Id: Delivered-To: mailing list commits@apr.apache.org Received: (qmail 72524 invoked by uid 99); 16 Apr 2008 05:39:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Apr 2008 22:39:08 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Apr 2008 05:38:24 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4502B1A983E; Tue, 15 Apr 2008 22:38:43 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r648530 - in /apr/apr/branches/1.3.x: CHANGES include/apr_pools.h memory/unix/apr_pools.c Date: Wed, 16 Apr 2008 05:38:42 -0000 To: commits@apr.apache.org From: mturk@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080416053843.4502B1A983E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mturk Date: Tue Apr 15 22:38:41 2008 New Revision: 648530 URL: http://svn.apache.org/viewvc?rev=648530&view=rev Log: Revert r647394. The API is incomplete and needs more development Modified: apr/apr/branches/1.3.x/CHANGES apr/apr/branches/1.3.x/include/apr_pools.h apr/apr/branches/1.3.x/memory/unix/apr_pools.c Modified: apr/apr/branches/1.3.x/CHANGES URL: http://svn.apache.org/viewvc/apr/apr/branches/1.3.x/CHANGES?rev=648530&r1=648529&r2=648530&view=diff ============================================================================== --- apr/apr/branches/1.3.x/CHANGES [utf-8] (original) +++ apr/apr/branches/1.3.x/CHANGES [utf-8] Tue Apr 15 22:38:41 2008 @@ -1,16 +1,6 @@ -*- coding: utf-8 -*- Changes for APR 1.3.0 - *) Introduce apr_pool_sys_allocator_set() for registering - application provided memory allocation functions that - will APR use internally whenever malloc/free is needed. - This allows to use custom memory allocators insted - sustem default malloc/free. This is one time initialization - function and must be used before any oter APR call. - After the first allocation function is called those - callbacks cannot be changed. - [Mladen Turk] - *) Introduce apr_pool_pre_cleanup_register() for registering a cleanup that is called before any subpool is destroyed within apr_pool_clear or apr_pool_destroy. Modified: apr/apr/branches/1.3.x/include/apr_pools.h URL: http://svn.apache.org/viewvc/apr/apr/branches/1.3.x/include/apr_pools.h?rev=648530&r1=648529&r2=648530&view=diff ============================================================================== --- apr/apr/branches/1.3.x/include/apr_pools.h (original) +++ apr/apr/branches/1.3.x/include/apr_pools.h Tue Apr 15 22:38:41 2008 @@ -149,40 +149,6 @@ * Initialization */ -/** A function that allocates memory from the system. */ -typedef void* (*apr_sys_alloc_t)(apr_size_t size, void *data); - -/** A function that allocates memory from the system. */ -typedef void* (*apr_sys_realloc_t)(void *mem, apr_size_t new_size, void *data); - -/** A function that frees memory. */ -typedef void (*apr_sys_free_t)(void *memory, void *data); - -/** - * Setup system memory alloc and free functions. - * - * If set APR will use those functions whenever it internally - * needs to allocate or free the memory. - * - * @param alloc_fn A function to use for allocating memory. - * @param alloc_data The data to pass to the alloc function. - * @param realloc_fn A function to use for reallocating memory. - * @param realloc_data The data to pass to the realloc function. - * @param free_fn A function to use for freeing memory. - * @param free_data The data to pass to the free function. - * @return APR_EINVAL if one of the functions is not provided. - * APR_EINIT if apr_pool_initialize was already called. - * @remark This function MUST be called before pool initializtion. - * If application don't set those functions the system - * will use malloc/realloc/free instead. - */ -APR_DECLARE(apr_status_t) apr_pool_sys_allocator_set(apr_sys_alloc_t alloc_fn, - void *alloc_data, - apr_sys_realloc_t realloc_fn, - void *realloc_data, - apr_sys_free_t free_fn, - void *free_data); - /** * Setup all of the internal structures required to use pools * @remark Programs do NOT need to call this directly. APR will call this Modified: apr/apr/branches/1.3.x/memory/unix/apr_pools.c URL: http://svn.apache.org/viewvc/apr/apr/branches/1.3.x/memory/unix/apr_pools.c?rev=648530&r1=648529&r2=648530&view=diff ============================================================================== --- apr/apr/branches/1.3.x/memory/unix/apr_pools.c (original) +++ apr/apr/branches/1.3.x/memory/unix/apr_pools.c Tue Apr 15 22:38:41 2008 @@ -100,44 +100,6 @@ #define SIZEOF_ALLOCATOR_T APR_ALIGN_DEFAULT(sizeof(apr_allocator_t)) -/* Global system allocator functions */ -static apr_sys_alloc_t global_allocfn = NULL; -static apr_sys_realloc_t global_reallocfn = NULL; -static apr_sys_free_t global_freefn = NULL; -static void *global_allocdata = NULL; -static void *global_reallocdata = NULL; -static void *global_freedata = NULL; - -/* - * System memory allocator - */ - -static APR_INLINE -void *APR_MALLOC(apr_size_t size) -{ - if (global_allocfn) - return (*global_allocfn)(size, global_allocdata); - else - return malloc(size); -} - -static APR_INLINE -void APR_FREE(void *mem) -{ - if (global_freefn) - (*global_freefn)(mem, global_freedata); - else - free(mem); -} - -static APR_INLINE -void *APR_REALLOC(void *mem, apr_size_t new_size) -{ - if (global_reallocfn) - return (*global_reallocfn)(mem, new_size, global_reallocdata); - else - return realloc(mem, new_size); -} /* * Allocator @@ -149,7 +111,7 @@ *allocator = NULL; - if ((new_allocator = APR_MALLOC(SIZEOF_ALLOCATOR_T)) == NULL) + if ((new_allocator = malloc(SIZEOF_ALLOCATOR_T)) == NULL) return APR_ENOMEM; memset(new_allocator, 0, SIZEOF_ALLOCATOR_T); @@ -169,11 +131,11 @@ ref = &allocator->free[index]; while ((node = *ref) != NULL) { *ref = node->next; - APR_FREE(node); + free(node); } } - APR_FREE(allocator); + free(allocator); } #if APR_HAS_THREADS @@ -358,7 +320,7 @@ /* If we haven't got a suitable node, malloc a new one * and initialize it. */ - if ((node = APR_MALLOC(size)) == NULL) + if ((node = malloc(size)) == NULL) return NULL; node->next = NULL; @@ -435,7 +397,7 @@ while (freelist != NULL) { node = freelist; freelist = node->next; - APR_FREE(node); + free(node); } } @@ -561,31 +523,6 @@ static apr_file_t *file_stderr = NULL; #endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) */ -APR_DECLARE(apr_status_t) apr_pool_sys_allocator_set(apr_sys_alloc_t alloc_fn, - void *alloc_data, - apr_sys_realloc_t realloc_fn, - void *realloc_data, - apr_sys_free_t free_fn, - void *free_data) -{ - if (apr_pools_initialized) { - /* We cannot intermix memory allocation functions */ - return APR_EINIT; - } - if (alloc_fn && realloc_fn && free_fn) { - global_allocfn = alloc_fn; - global_reallocfn = realloc_fn; - global_freefn = free_fn; - global_allocdata = alloc_data; - global_reallocdata = realloc_data; - global_freedata = free_data; - - return APR_SUCCESS; - } - else - return APR_EINVAL; -} - /* * Local functions */ @@ -983,7 +920,7 @@ if (!apr_pools_initialized) return APR_ENOPOOL; if ((pool_allocator = allocator) == NULL) { - if ((pool_allocator = APR_MALLOC(SIZEOF_ALLOCATOR_T)) == NULL) { + if ((pool_allocator = malloc(SIZEOF_ALLOCATOR_T)) == NULL) { if (abort_fn) abort_fn(APR_ENOMEM); @@ -1468,7 +1405,7 @@ debug_node_t *node; void *mem; - if ((mem = APR_MALLOC(size)) == NULL) { + if ((mem = malloc(size)) == NULL) { if (pool->abort_fn) pool->abort_fn(APR_ENOMEM); @@ -1477,7 +1414,7 @@ node = pool->nodes; if (node == NULL || node->index == 64) { - if ((node = APR_MALLOC(SIZEOF_DEBUG_NODE_T)) == NULL) { + if ((node = malloc(SIZEOF_DEBUG_NODE_T)) == NULL) { if (pool->abort_fn) pool->abort_fn(APR_ENOMEM); @@ -1581,11 +1518,11 @@ for (index = 0; index < node->index; index++) { memset(node->beginp[index], POOL_POISON_BYTE, (char *)node->endp[index] - (char *)node->beginp[index]); - APR_FREE(node->beginp[index]); + free(node->beginp[index]); } memset(node, POOL_POISON_BYTE, SIZEOF_DEBUG_NODE_T); - APR_FREE(node); + free(node); } pool->stat_alloc = 0; @@ -1669,7 +1606,7 @@ } /* Free the pool itself */ - APR_FREE(pool); + free(pool); } APR_DECLARE(void) apr_pool_destroy_debug(apr_pool_t *pool, @@ -1711,7 +1648,7 @@ if (!abort_fn && parent) abort_fn = parent->abort_fn; - if ((pool = APR_MALLOC(SIZEOF_POOL_T)) == NULL) { + if ((pool = malloc(SIZEOF_POOL_T)) == NULL) { if (abort_fn) abort_fn(APR_ENOMEM); @@ -1768,7 +1705,7 @@ */ if ((rv = apr_thread_mutex_create(&pool->mutex, APR_THREAD_MUTEX_NESTED, pool)) != APR_SUCCESS) { - APR_FREE(pool); + free(pool); return rv; } #endif /* APR_HAS_THREADS */ @@ -1799,7 +1736,7 @@ *newpool = NULL; - if ((pool = APR_MALLOC(SIZEOF_POOL_T)) == NULL) { + if ((pool = malloc(SIZEOF_POOL_T)) == NULL) { if (abort_fn) abort_fn(APR_ENOMEM); @@ -1844,7 +1781,7 @@ */ if ((rv = apr_thread_mutex_create(&pool->mutex, APR_THREAD_MUTEX_NESTED, pool)) != APR_SUCCESS) { - APR_FREE(pool); + free(pool); return rv; } #endif /* APR_HAS_THREADS */ @@ -1877,7 +1814,7 @@ size = ps->vbuff.curpos - ps->mem; ps->size <<= 1; - if ((ps->mem = APR_REALLOC(ps->mem, ps->size)) == NULL) + if ((ps->mem = realloc(ps->mem, ps->size)) == NULL) return -1; ps->vbuff.curpos = ps->mem + size; @@ -1894,7 +1831,7 @@ apr_pool_check_integrity(pool); ps.size = 64; - ps.mem = APR_MALLOC(ps.size); + ps.mem = malloc(ps.size); ps.vbuff.curpos = ps.mem; /* Save a byte for the NUL terminator */ @@ -1914,7 +1851,7 @@ */ node = pool->nodes; if (node == NULL || node->index == 64) { - if ((node = APR_MALLOC(SIZEOF_DEBUG_NODE_T)) == NULL) { + if ((node = malloc(SIZEOF_DEBUG_NODE_T)) == NULL) { if (pool->abort_fn) pool->abort_fn(APR_ENOMEM);