Quoting Bojan Smojver <[EMAIL PROTECTED]>:

Like the attached, perhaps?

Not quite.

The caller would have no way of determining the size of the apr_dso_handle_t, therefore it would not be possible to allocate this structure. Ah well, here is a version with calloc(). Since we wouldn't be doing anything with pools here and it would be "for the duration of the process", I guess we should be OK.

--
Bojan
Index: include/apr_dso.h
===================================================================
--- include/apr_dso.h	(revision 432465)
+++ include/apr_dso.h	(working copy)
@@ -50,9 +50,10 @@
 
 /**
  * Load a DSO library.
- * @param res_handle Location to store new handle for the DSO.
+ * @param res_handle Location to store new handle for the DSO (if pool is
+ *                   NULL, it will be allocated using malloc())
  * @param path Path to the DSO library
- * @param ctx Pool to use.
+ * @param ctx Pool to use or NULL for none
  * @bug We aught to provide an alternative to RTLD_GLOBAL, which
  * is the only supported method of loading DSOs today.
  */
Index: dso/unix/dso.c
===================================================================
--- dso/unix/dso.c	(revision 432465)
+++ dso/unix/dso.c	(working copy)
@@ -140,7 +140,12 @@
 #endif    
 #endif /* DSO_USE_x */
 
-    *res_handle = apr_pcalloc(pool, sizeof(**res_handle));
+    if (pool) {
+        *res_handle = apr_pcalloc(pool, sizeof(**res_handle));
+    }
+    else {
+        *res_handle = calloc(1, sizeof(**res_handle));
+    }
 
     if(os_handle == NULL) {
 #if defined(DSO_USE_SHL)
@@ -159,14 +164,22 @@
     (*res_handle)->pool = pool;
     (*res_handle)->errormsg = NULL;
 
-    apr_pool_cleanup_register(pool, *res_handle, dso_cleanup, apr_pool_cleanup_null);
+    if (pool) {
+        apr_pool_cleanup_register(pool, *res_handle, dso_cleanup,
+                                  apr_pool_cleanup_null);
+    }
 
     return APR_SUCCESS;
 }
     
 APR_DECLARE(apr_status_t) apr_dso_unload(apr_dso_handle_t *handle)
 {
-    return apr_pool_cleanup_run(handle->pool, handle, dso_cleanup);
+    if (handle->pool) {
+        return apr_pool_cleanup_run(handle->pool, handle, dso_cleanup);
+    }
+    else {
+        return APR_SUCCESS;
+    }
 }
 
 APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym, 

Reply via email to