gstein 00/12/06 12:02:35
Modified: lib apr_pools.c
misc/unix start.c
Log:
put the pool functions in the pool code.
Revision Changes Path
1.74 +68 -0 apr/lib/apr_pools.c
Index: apr_pools.c
===================================================================
RCS file: /home/cvs/apr/lib/apr_pools.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -u -r1.73 -r1.74
--- apr_pools.c 2000/12/01 06:27:16 1.73
+++ apr_pools.c 2000/12/06 20:02:34 1.74
@@ -68,6 +68,7 @@
#include "apr_pools.h"
#include "apr_lib.h"
#include "apr_lock.h"
+#include "apr_hash.h"
#ifdef HAVE_STDIO_H
#include <stdio.h>
@@ -530,6 +531,33 @@
}
#endif
+/* ### why do we have this, in addition to apr_make_sub_pool? */
+apr_status_t apr_create_pool(apr_pool_t **newcont, apr_pool_t *cont)
+{
+ apr_pool_t *newpool;
+
+ if (cont) {
+ newpool = apr_make_sub_pool(cont, cont->apr_abort);
+ }
+ else {
+ newpool = apr_make_sub_pool(NULL, NULL);
+ }
+
+ if (newpool == NULL) {
+ return APR_ENOPOOL;
+ }
+
+ newpool->prog_data = NULL;
+ if (cont) {
+ newpool->apr_abort = cont->apr_abort;
+ }
+ else {
+ newpool->apr_abort = NULL;
+ }
+ *newcont = newpool;
+ return APR_SUCCESS;
+}
+
/*****************************************************************
*
* Managing generic cleanups.
@@ -960,6 +988,46 @@
memset(res, '\0', size);
return res;
}
+
+/*****************************************************************
+ *
+ * User data management functions
+ */
+
+apr_status_t apr_set_userdata(const void *data, const char *key,
+ apr_status_t (*cleanup) (void *),
+ apr_pool_t *cont)
+{
+ int keylen = strlen(key);
+
+ if (cont->prog_data == NULL)
+ cont->prog_data = apr_make_hash(cont);
+
+ if (apr_hash_get(cont->prog_data, key, keylen) == NULL){
+ char *new_key = apr_pstrdup(cont, key);
+ apr_hash_set(cont->prog_data, new_key, keylen, data);
+ }
+ else {
+ apr_hash_set(cont->prog_data, key, keylen, data);
+ }
+
+ apr_register_cleanup(cont, data, cleanup, cleanup);
+ return APR_SUCCESS;
+}
+
+apr_status_t apr_get_userdata(void **data, const char *key, apr_pool_t *cont)
+{
+ if (cont->prog_data == NULL)
+ *data = NULL;
+ else
+ *data = apr_hash_get(cont->prog_data, key, strlen(key));
+ return APR_SUCCESS;
+}
+
+/*****************************************************************
+ *
+ * "Print" functions
+ */
/*
* apr_psprintf is implemented by writing directly into the current
1.44 +6 -58 apr/misc/unix/start.c
Index: start.c
===================================================================
RCS file: /home/cvs/apr/misc/unix/start.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -u -r1.43 -r1.44
--- start.c 2000/12/06 19:40:41 1.43
+++ start.c 2000/12/06 20:02:35 1.44
@@ -52,68 +52,16 @@
* <http://www.apache.org/>.
*/
-#include "misc.h"
-#include "locks.h"
-#include "apr_strings.h"
-#include "apr_hash.h"
+#include "apr.h"
+#include "apr_general.h"
+#include "apr_pools.h"
-static int initialized=0;
+#include "misc.h" /* for WSAHighByte / WSALowByte */
+#include "locks.h" /* for apr_unix_setup_lock() */
-apr_status_t apr_create_pool(apr_pool_t **newcont, apr_pool_t *cont)
-{
- apr_pool_t *newpool;
- if (cont) {
- newpool = apr_make_sub_pool(cont, cont->apr_abort);
- }
- else {
- newpool = apr_make_sub_pool(NULL, NULL);
- }
-
- if (newpool == NULL) {
- return APR_ENOPOOL;
- }
+static int initialized = 0;
- newpool->prog_data = NULL;
- if (cont) {
- newpool->apr_abort = cont->apr_abort;
- }
- else {
- newpool->apr_abort = NULL;
- }
- *newcont = newpool;
- return APR_SUCCESS;
-}
-
-apr_status_t apr_set_userdata(const void *data, const char *key,
- apr_status_t (*cleanup) (void *),
- apr_pool_t *cont)
-{
- int keylen = strlen(key);
-
- if (cont->prog_data == NULL)
- cont->prog_data = apr_make_hash(cont);
-
- if (apr_hash_get(cont->prog_data, key, keylen) == NULL){
- char *new_key = apr_pstrdup(cont, key);
- apr_hash_set(cont->prog_data, new_key, keylen, data);
- }
- else {
- apr_hash_set(cont->prog_data, key, keylen, data);
- }
-
- apr_register_cleanup(cont, data, cleanup, cleanup);
- return APR_SUCCESS;
-}
-
-apr_status_t apr_get_userdata(void **data, const char *key, apr_pool_t *cont)
-{
- if (cont->prog_data == NULL)
- *data = NULL;
- else
- *data = apr_hash_get(cont->prog_data, key, strlen(key));
- return APR_SUCCESS;
-}
apr_status_t apr_initialize(void)
{