summaryrefslogtreecommitdiff
path: root/acconfig.h
diff options
context:
space:
mode:
authordreid <dreid@13f79535-47bb-0310-9956-ffa450edef68>2001-06-05 08:15:37 +0000
committerdreid <dreid@13f79535-47bb-0310-9956-ffa450edef68>2001-06-05 08:15:37 +0000
commit51a551acabdd690d61b32a140eb35c1fa21df005 (patch)
treebd5d646a7be4fa86989e31aba06d7880d7278acc /acconfig.h
parent617d7f11c673551685b5fef657acca30797835f9 (diff)
downloadlibapr-51a551acabdd690d61b32a140eb35c1fa21df005.tar.gz
OK, this basically adds a function that allows us to create
apr_lock_t's using an apr_sms_t for the memory. It's a very small first step, and at present is only intended to be used internally in APR, hence the position of the function definitions in the locks.h file. Given that we don't want to duplicate code where we don't have to, I've added some macros that allow us to do memory allocations regardless of whether we have a pool or sms. This also highlighted that we haven't yet managed to change our member names from cntxt to pool everywhere! The surprise comes in just how far reaching the apr_pool_t goes. As apr_lock.h uses ap_sms_t and apr_sms.h uses apr_lock_t I've moved the tyepdef's into apr.h.in, but this may be bogus... Hopefully this will allow us to get locking into sms and so start moving forward again, and at the same time it starts to throw up the problems for changing our memory system throughout APR. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@61698 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'acconfig.h')
-rw-r--r--acconfig.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/acconfig.h b/acconfig.h
index b238713b5..35aa1f9b6 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -67,4 +67,46 @@
#define apr_sigwait(a,b) sigwait((a),(b))
#endif
+/* Macros to deal with using either a pool or an sms
+ * to do memory stuff...
+ */
+#define APR_REGISTER_CLEANUP(struct, data, func, scope) \
+ if (struct->cntxt) { \
+ apr_pool_cleanup_register(struct->cntxt, data, func, scope); \
+ } else { \
+ apr_sms_cleanup_register(struct->mem_sys, APR_CHILD_CLEANUP, \
+ data, func); \
+ }
+
+#define APR_REMOVE_CLEANUP(struct, data, func) \
+ if (struct->cntxt) { \
+ apr_pool_cleanup_kill(struct->cntxt, data, func); \
+ } else { \
+ apr_sms_cleanup_unregister(struct->mem_sys, APR_CHILD_CLEANUP, \
+ data, func); \
+ }
+
+#define APR_MEM_PSTRDUP(struct, ptr, str) \
+ if (struct->cntxt) { \
+ ptr = apr_pstrdup(struct->cntxt, str); \
+ } else { \
+ size_t len = strlen(str) + 1; \
+ ptr = (char*) apr_sms_calloc(struct->mem_sys, len); \
+ memcpy(ptr, str, len); \
+ }
+
+#define APR_MEM_MALLOC(ptr, struct, type) \
+ if (struct->cntxt) { \
+ ptr = (type *)apr_palloc(struct->cntxt, sizeof(type)); \
+ } else { \
+ ptr = (type *)apr_sms_malloc(struct->mem_sys, sizeof(type)); \
+ }
+
+#define APR_MEM_CALLOC(ptr, struct, type) \
+ if (struct->cntxt) { \
+ ptr = (type *)apr_pcalloc(struct->cntxt, sizeof(type)); \
+ } else { \
+ ptr = (type *)apr_sms_calloc(struct->mem_sys, sizeof(type)); \
+ }
+
#endif /* APR_PRIVATE_H */