apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r795381 - in /apr/apr/trunk: include/apr_pools.h memory/unix/apr_pools.c
Date Sat, 18 Jul 2009 14:39:59 GMT
Author: mturk
Date: Sat Jul 18 14:39:58 2009
New Revision: 795381

URL: http://svn.apache.org/viewvc?rev=795381&view=rev
Log:
Add unmanaged pools from 1.4 branch

Modified:
    apr/apr/trunk/include/apr_pools.h
    apr/apr/trunk/memory/unix/apr_pools.c

Modified: apr/apr/trunk/include/apr_pools.h
URL: http://svn.apache.org/viewvc/apr/apr/trunk/include/apr_pools.h?rev=795381&r1=795380&r2=795381&view=diff
==============================================================================
--- apr/apr/trunk/include/apr_pools.h (original)
+++ apr/apr/trunk/include/apr_pools.h Sat Jul 18 14:39:58 2009
@@ -189,6 +189,23 @@
                                              apr_allocator_t *allocator);
 
 /**
+ * Create a new unmanaged pool.
+ * @param newpool The pool we have just created.
+ * @param abort_fn A function to use if the pool cannot allocate more memory.
+ * @param allocator The allocator to use with the new pool.  If NULL a
+ *        new allocator will be crated with newpool as owner.
+ * @remark An unmanaged pool is a special pool without a parent; it will
+ *         NOT be destroyed upon apr_terminate.  It must be explicitly
+ *         destroyed by calling apr_pool_destroy, to prevent memory leaks.
+ *         Use of this function is discouraged, think twice about whether
+ *         you really really need it.
+ */
+APR_DECLARE(apr_status_t) apr_pool_create_unmanaged_ex(apr_pool_t **newpool,
+                                                   apr_abortfunc_t abort_fn,
+                                                   apr_allocator_t *allocator);
+
+
+/**
  * Debug version of apr_pool_create_ex.
  * @param newpool @see apr_pool_create.
  * @param parent @see apr_pool_create.
@@ -210,10 +227,33 @@
                                                    apr_allocator_t *allocator,
                                                    const char *file_line);
 
+/**
+ * Debug version of apr_pool_create_unmanaged_ex.
+ * @param newpool @see apr_pool_create_unmanaged.
+ * @param abort_fn @see apr_pool_create_unmanaged.
+ * @param allocator @see apr_pool_create_unmanaged.
+ * @param file_line Where the function is called from.
+ *        This is usually APR_POOL__FILE_LINE__.
+ * @remark Only available when APR_POOL_DEBUG is defined.
+ *         Call this directly if you have you apr_pool_create_unmanaged_ex
+ *         calls in a wrapper function and wish to override
+ *         the file_line argument to reflect the caller of
+ *         your wrapper function.  If you do not have
+ *         apr_pool_create_core_ex in a wrapper, trust the macro
+ *         and don't call apr_pool_create_core_ex_debug directly.
+ */
+APR_DECLARE(apr_status_t) apr_pool_create_unmanaged_ex_debug(apr_pool_t **newpool,
+                                                   apr_abortfunc_t abort_fn,
+                                                   apr_allocator_t *allocator,
+                                                   const char *file_line);
+
 #if APR_POOL_DEBUG
 #define apr_pool_create_ex(newpool, parent, abort_fn, allocator)  \
     apr_pool_create_ex_debug(newpool, parent, abort_fn, allocator, \
                              APR_POOL__FILE_LINE__)
+#define apr_pool_create_unmanaged_ex(newpool, abort_fn, allocator)  \
+    apr_pool_create_unmanaged_ex_debug(newpool, abort_fn, allocator, \
+                                  APR_POOL__FILE_LINE__)
 #endif
 
 /**

Modified: apr/apr/trunk/memory/unix/apr_pools.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/memory/unix/apr_pools.c?rev=795381&r1=795380&r2=795381&view=diff
==============================================================================
--- apr/apr/trunk/memory/unix/apr_pools.c (original)
+++ apr/apr/trunk/memory/unix/apr_pools.c Sat Jul 18 14:39:58 2009
@@ -796,22 +796,15 @@
     free(pool);
 }
 
-APR_DECLARE(apr_status_t) apr_pool_create_ex(apr_pool_t **newpool,
-                                             apr_pool_t *parent,
-                                             apr_abortfunc_t abort_fn,
-                                             apr_allocator_t *allocator)
+static apr_status_t internal_pool_create_ex(apr_pool_t **newpool,
+                                            apr_pool_t *parent,
+                                            apr_abortfunc_t abort_fn,
+                                            apr_allocator_t *allocator)
 {
     apr_pool_t *pool;
 
     *newpool = NULL;
 
-    if (!parent)
-        parent = global_pool;
-
-    /* parent will always be non-NULL here except the first time a
-     * pool is created, in which case allocator is guaranteed to be
-     * non-NULL. */
-
     if (!abort_fn && parent)
         abort_fn = parent->abort_fn;
 
@@ -880,6 +873,28 @@
     return APR_SUCCESS;
 }
 
+APR_DECLARE(apr_status_t) apr_pool_create_ex(apr_pool_t **newpool,
+                                             apr_pool_t *parent,
+                                             apr_abortfunc_t abort_fn,
+                                             apr_allocator_t *allocator)
+{
+    if (!parent)
+        parent = global_pool;
+
+    /* parent will always be non-NULL here except the first time a
+     * pool is created, in which case allocator is guaranteed to be
+     * non-NULL. */
+    return internal_pool_create_ex(newpool, parent, abort_fn, allocator);
+}
+
+APR_DECLARE(apr_status_t) apr_pool_create_unmanaged_ex(apr_pool_t **newpool,
+                                                  apr_abortfunc_t abort_fn,
+                                                  apr_allocator_t *allocator)
+{
+    /* unmanaged pools have no parent. */
+    return internal_pool_create_ex(newpool, NULL, abort_fn, allocator);
+}
+
 /*
  * "Print" functions
  */
@@ -1405,26 +1420,16 @@
     pool_destroy_debug(pool, file_line);
 }
 
-APR_DECLARE(apr_status_t) apr_pool_create_ex_debug(apr_pool_t **newpool,
-                                                   apr_pool_t *parent,
-                                                   apr_abortfunc_t abort_fn,
-                                                   apr_allocator_t *allocator,
-                                                   const char *file_line)
+static apr_status_t internal_pool_create_ex_debug(apr_pool_t **newpool,
+                                                  apr_pool_t *parent,
+                                                  apr_abortfunc_t abort_fn,
+                                                  apr_allocator_t *allocator,
+                                                  const char *file_line)
 {
     apr_pool_t *pool;
 
     *newpool = NULL;
 
-    if (!parent) {
-        parent = global_pool;
-    }
-    else {
-       apr_pool_check_integrity(parent);
-
-       if (!allocator)
-           allocator = parent->allocator;
-    }
-
     if (!abort_fn && parent)
         abort_fn = parent->abort_fn;
 
@@ -1506,6 +1511,34 @@
     return APR_SUCCESS;
 }
 
+APR_DECLARE(apr_status_t) apr_pool_create_ex_debug(apr_pool_t **newpool,
+                                                   apr_pool_t *parent,
+                                                   apr_abortfunc_t abort_fn,
+                                                   apr_allocator_t *allocator,
+                                                   const char *file_line)
+{
+    if (!parent) {
+        parent = global_pool;
+    }
+    else {
+       apr_pool_check_integrity(parent);
+
+       if (!allocator)
+           allocator = parent->allocator;
+    }
+    return internal_pool_create_ex_debug(newpool, parent, abort_fn, allocator,
+                                         file_line);
+}
+
+APR_DECLARE(apr_status_t) apr_pool_create_unmanaged_ex_debug(apr_pool_t **newpool,
+                                                   apr_abortfunc_t abort_fn,
+                                                   apr_allocator_t *allocator,
+                                                   const char *file_line)
+{
+    return internal_pool_create_ex_debug(newpool, NULL, abort_fn, allocator,
+                                         file_line);
+}
+
 /*
  * "Print" functions (debug)
  */
@@ -2254,4 +2287,20 @@
                                     "undefined");
 }
 
+#undef apr_pool_create_unmanaged_ex
+APR_DECLARE(apr_status_t) apr_pool_create_unmanaged_ex(apr_pool_t **newpool,
+                                                    apr_pool_t *parent,
+                                                    apr_abortfunc_t abort_fn,
+                                                    apr_allocator_t *allocator);
+
+APR_DECLARE(apr_status_t) apr_pool_create_unmanaged_ex(apr_pool_t **newpool,
+                                                    apr_pool_t *parent,
+                                                    apr_abortfunc_t abort_fn,
+                                                    apr_allocator_t *allocator)
+{
+    return apr_pool_create_unmanaged_ex_debug(newpool, parent,
+                                              abort_fn, allocator,
+                                              "undefined");
+}
+
 #endif /* APR_POOL_DEBUG */



Mime
View raw message