summaryrefslogtreecommitdiff
path: root/memory
diff options
context:
space:
mode:
authorwrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68>2001-10-29 14:54:19 +0000
committerwrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68>2001-10-29 14:54:19 +0000
commit50dcee6c40b360eb96bb901de3e6381f66b225da (patch)
tree945b0e7c1f3dca5e0b1c92f7067e59081cae4f78 /memory
parent6df41c00fdca5907f566675f4271c2c710ad1cfd (diff)
downloadlibapr-50dcee6c40b360eb96bb901de3e6381f66b225da.tar.gz
Introduce the apr_pool_userdata_setn() variant that doesn't strdup the key.
Support for passing NULL as the cleanup callback, so items that don't require a cleanup need not incur the overhead of registering a no-op. Submitted by: Brian Pane <bpane@pacbell.net> git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@62473 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'memory')
-rw-r--r--memory/unix/apr_pools.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/memory/unix/apr_pools.c b/memory/unix/apr_pools.c
index fd0ba05cb..5f043f77e 100644
--- a/memory/unix/apr_pools.c
+++ b/memory/unix/apr_pools.c
@@ -1284,7 +1284,26 @@ APR_DECLARE(apr_status_t) apr_pool_userdata_set(const void *data, const char *ke
apr_hash_set(cont->prog_data, key, keylen, data);
}
- apr_pool_cleanup_register(cont, data, cleanup, cleanup);
+ if (cleanup) {
+ apr_pool_cleanup_register(cont, data, cleanup, cleanup);
+ }
+ return APR_SUCCESS;
+}
+
+APR_DECLARE(apr_status_t) apr_pool_userdata_setn(const void *data, const char *key,
+ apr_status_t (*cleanup) (void *),
+ apr_pool_t *cont)
+{
+ apr_size_t keylen = strlen(key);
+
+ if (cont->prog_data == NULL)
+ cont->prog_data = apr_hash_make(cont);
+
+ apr_hash_set(cont->prog_data, key, keylen, data);
+
+ if (cleanup) {
+ apr_pool_cleanup_register(cont, data, cleanup, cleanup);
+ }
return APR_SUCCESS;
}