summaryrefslogtreecommitdiff
path: root/memory
diff options
context:
space:
mode:
authordreid <dreid@13f79535-47bb-0310-9956-ffa450edef68>2001-07-07 13:03:46 +0000
committerdreid <dreid@13f79535-47bb-0310-9956-ffa450edef68>2001-07-07 13:03:46 +0000
commit4f077870441647ff9332be163762c0f6bfc6b60d (patch)
treeb5bb295bcddb32ef5ce7c2775556e1cd3d2f9345 /memory
parentc0547e18d6fc1e0749f4abb125aea60943a6a4cb (diff)
downloadlibapr-4f077870441647ff9332be163762c0f6bfc6b60d.tar.gz
Few changes, mainly to add more support for sms :)
- add apr_sms_userdata_get/set routines - change testcontext into testud as all it does is test user data - add a test for sms user data into testud - remove testcontext as we haven't been calling our memory contexts for a very long time now :) git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@61890 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'memory')
-rw-r--r--memory/unix/apr_sms.c36
-rw-r--r--memory/unix/sms_private.h1
2 files changed, 36 insertions, 1 deletions
diff --git a/memory/unix/apr_sms.c b/memory/unix/apr_sms.c
index ed2a5a12a..5e7657f5c 100644
--- a/memory/unix/apr_sms.c
+++ b/memory/unix/apr_sms.c
@@ -64,9 +64,12 @@
#include "apr_general.h"
#include "apr_sms.h"
#include <stdlib.h>
-#include "sms_private.h"
+#include "apr_hash.h"
+#include "apr_strings.h"
#include "apr_portable.h"
+#include "sms_private.h"
+
#ifdef APR_ASSERT_MEMORY
#include <assert.h>
#endif
@@ -922,6 +925,37 @@ APR_DECLARE(apr_abortfunc_t) apr_sms_get_abort(apr_sms_t *sms)
return sms->apr_abort;
}
+APR_DECLARE(apr_status_t) apr_sms_userdata_set(const void *data,
+ const char *key,
+ apr_status_t (*cleanup)(void*),
+ apr_sms_t *sms)
+{
+ apr_size_t keylen = strlen(key);
+
+ if (sms->prog_data == NULL)
+ sms->prog_data = apr_hash_make(sms->pool);
+
+ if (apr_hash_get(sms->prog_data, key, keylen) == NULL) {
+ char *new_key = apr_pstrdup((apr_pool_t*)sms->pool, key);
+ apr_hash_set(sms->prog_data, new_key, keylen, data);
+ } else {
+ apr_hash_set(sms->prog_data, key, keylen, data);
+ }
+
+ apr_sms_cleanup_register(sms, APR_GENERAL_CLEANUP, data, cleanup);
+ return APR_SUCCESS;
+}
+
+APR_DECLARE(apr_status_t) apr_sms_userdata_get(void **data, const char *key,
+ apr_sms_t *sms)
+{
+ if (sms->prog_data == NULL)
+ *data = NULL;
+ else
+ *data = apr_hash_get(sms->prog_data, key, strlen(key));
+ return APR_SUCCESS;
+}
+
#if APR_DEBUG_SHOW_STRUCTURE
static void add_sms(char *a, char *b, char *c, apr_sms_t *sms,
apr_sms_t *caller, int sib)
diff --git a/memory/unix/sms_private.h b/memory/unix/sms_private.h
index c753bc93e..ddd4d880d 100644
--- a/memory/unix/sms_private.h
+++ b/memory/unix/sms_private.h
@@ -94,6 +94,7 @@ struct apr_sms_t
apr_status_t (*unlock_fn) (apr_sms_t *sms);
apr_status_t (*apr_abort)(int retcode);
+ struct apr_hash_t *prog_data;
#if APR_HAS_THREADS
apr_status_t (*thread_register_fn) (apr_sms_t *sms,