apr_pool_cleanup_register's 3rd and 4th arguments must not be NULL.
If we want a pool to do nothing at the destruction, we must pass 
apr_pool_cleanup_null.
apr_pool_userdata_set accepts NULL as cleanup function. I think this is natural 
and safe.
Al least when APR_POOL_DEBUG enabled there should be some assertion.

Additionally if apr_pool_cleanup_register accepts NULL apr_pool_cleanup_null no 
longer have to be a public API.

-- 
Takashi Sato
[EMAIL PROTECTED]
Index: memory/unix/apr_pools.c
===================================================================
--- memory/unix/apr_pools.c     (revision 596869)
+++ memory/unix/apr_pools.c     (working copy)
@@ -2004,8 +2004,8 @@
             c = apr_palloc(p, sizeof(cleanup_t));
         }
         c->data = data;
-        c->plain_cleanup_fn = plain_cleanup_fn;
-        c->child_cleanup_fn = child_cleanup_fn;
+        c->plain_cleanup_fn = plain_cleanup_fn ? plain_cleanup_fn : 
apr_pool_cleanup_null;
+        c->child_cleanup_fn = child_cleanup_fn ? child_cleanup_fn : 
apr_pool_cleanup_null;
         c->next = p->cleanups;
         p->cleanups = c;
     }

Index: memory/unix/apr_pools.c
===================================================================
--- memory/unix/apr_pools.c     (revision 596869)
+++ memory/unix/apr_pools.c     (working copy)
@@ -2004,6 +2004,11 @@
             c = apr_palloc(p, sizeof(cleanup_t));
         }
         c->data = data;
+#if APR_POOL_DEBUG
+        if (!plain_cleanup_fn || !child_cleanup_fn) {
+            abort();
+        }
+#endif
         c->plain_cleanup_fn = plain_cleanup_fn;
         c->child_cleanup_fn = child_cleanup_fn;
         c->next = p->cleanups;

Reply via email to