jwoolley 01/02/28 09:52:48
Modified: . CHANGES
buckets apr_buckets_file.c apr_buckets_heap.c
apr_buckets_mmap.c apr_buckets_pool.c
apr_buckets_refcount.c
include apr_buckets.h
Log:
apr_bucket_shared_destroy() now returns a boolean value
instead of a pointer, since the caller already knew the
pointer value anyway. (Issue #8 from the "Bucket API
cleanup issues" thread.)
Revision Changes Path
1.4 +3 -0 apr-util/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/apr-util/CHANGES,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -u -r1.3 -r1.4
--- CHANGES 2001/02/28 15:19:40 1.3
+++ CHANGES 2001/02/28 17:52:40 1.4
@@ -1,5 +1,8 @@
Changes with APR-util b1
+ *) apr_bucket_shared_destroy() now returns a boolean value.
+ [Cliff Woolley]
+
*) We have to initialize the heap buckets to the correct length.
we were seeing heap buckets with 17 chars in them reporting
a length of 9017, because they were initialized to the amount
1.38 +3 -5 apr-util/buckets/apr_buckets_file.c
Index: apr_buckets_file.c
===================================================================
RCS file: /home/cvs/apr-util/buckets/apr_buckets_file.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -u -r1.37 -r1.38
--- apr_buckets_file.c 2001/02/28 17:18:59 1.37
+++ apr_buckets_file.c 2001/02/28 17:52:42 1.38
@@ -86,13 +86,11 @@
static void file_destroy(void *data)
{
- apr_bucket_file *f;
+ apr_bucket_file *f = data;
- f = apr_bucket_shared_destroy(data);
- if (f == NULL) {
- return;
+ if (apr_bucket_shared_destroy(data)) {
+ free(f);
}
- free(f);
}
static apr_status_t file_read(apr_bucket *e, const char **str,
1.29 +4 -6 apr-util/buckets/apr_buckets_heap.c
Index: apr_buckets_heap.c
===================================================================
RCS file: /home/cvs/apr-util/buckets/apr_buckets_heap.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -u -r1.28 -r1.29
--- apr_buckets_heap.c 2001/02/27 20:45:36 1.28
+++ apr_buckets_heap.c 2001/02/28 17:52:43 1.29
@@ -70,14 +70,12 @@
static void heap_destroy(void *data)
{
- apr_bucket_heap *h;
+ apr_bucket_heap *h = data;
- h = apr_bucket_shared_destroy(data);
- if (h == NULL) {
- return;
+ if (apr_bucket_shared_destroy(data)) {
+ free(h->base);
+ free(h);
}
- free(h->base);
- free(h);
}
APU_DECLARE(apr_bucket *) apr_bucket_heap_make(apr_bucket *b,
1.31 +3 -5 apr-util/buckets/apr_buckets_mmap.c
Index: apr_buckets_mmap.c
===================================================================
RCS file: /home/cvs/apr-util/buckets/apr_buckets_mmap.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -u -r1.30 -r1.31
--- apr_buckets_mmap.c 2001/02/27 20:45:36 1.30
+++ apr_buckets_mmap.c 2001/02/28 17:52:43 1.31
@@ -78,12 +78,10 @@
{
apr_bucket_mmap *m;
- m = apr_bucket_shared_destroy(data);
- if (m == NULL) {
- return;
+ if (apr_bucket_shared_destroy(data)) {
+ /* XXX: apr_mmap_delete(m->mmap)? */
+ free(m);
}
- /* XXX: apr_mmap_delete(m->mmap)? */
- free(m);
}
/*
1.14 +2 -4 apr-util/buckets/apr_buckets_pool.c
Index: apr_buckets_pool.c
===================================================================
RCS file: /home/cvs/apr-util/buckets/apr_buckets_pool.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -u -r1.13 -r1.14
--- apr_buckets_pool.c 2001/02/27 20:45:36 1.13
+++ apr_buckets_pool.c 2001/02/28 17:52:43 1.14
@@ -89,11 +89,9 @@
apr_bucket_pool *h = data;
apr_pool_cleanup_kill(h->p, data, pool_bucket_cleanup);
- h = apr_bucket_shared_destroy(data);
- if (h == NULL) {
- return;
+ if (apr_bucket_shared_destroy(data)) {
+ free(h);
}
- free(h);
}
APU_DECLARE(apr_bucket *) apr_bucket_pool_make(apr_bucket *b,
1.16 +2 -7 apr-util/buckets/apr_buckets_refcount.c
Index: apr_buckets_refcount.c
===================================================================
RCS file: /home/cvs/apr-util/buckets/apr_buckets_refcount.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -u -r1.15 -r1.16
--- apr_buckets_refcount.c 2001/02/27 20:45:36 1.15
+++ apr_buckets_refcount.c 2001/02/28 17:52:44 1.16
@@ -52,10 +52,6 @@
* <http://www.apache.org/>.
*/
-#include <stdlib.h>
-
-#include "apr_errno.h"
-
#include "apr_buckets.h"
APU_DECLARE_NONSTD(apr_status_t) apr_bucket_shared_split(apr_bucket *a,
@@ -86,12 +82,11 @@
return APR_SUCCESS;
}
-/* XXX: can this just return true or false? */
-APU_DECLARE(void *) apr_bucket_shared_destroy(void *data)
+APU_DECLARE(int) apr_bucket_shared_destroy(void *data)
{
apr_bucket_refcount *r = data;
r->refcount--;
- return (r->refcount == 0) ? r : NULL;
+ return (r->refcount == 0);
}
APU_DECLARE(apr_bucket *) apr_bucket_shared_make(apr_bucket *b, void *data,
1.86 +5 -5 apr-util/include/apr_buckets.h
Index: apr_buckets.h
===================================================================
RCS file: /home/cvs/apr-util/include/apr_buckets.h,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -d -u -r1.85 -r1.86
--- apr_buckets.h 2001/02/28 17:19:05 1.85
+++ apr_buckets.h 2001/02/28 17:52:46 1.86
@@ -942,12 +942,12 @@
* Decrement the refcount of the data in the bucket. This function
* should only be called by type-specific bucket destruction functions.
* @param data The private data pointer from the bucket to be destroyed
- * @return NULL if nothing needs to be done,
- * otherwise a pointer to the private data structure which
- * must be destroyed because its reference count is zero
- * @deffunc void *apr_bucket_shared_destroy(void *data)
+ * @return TRUE or FALSE; TRUE if the reference count is now
+ * zero, indicating that the shared resource itself can
+ * be destroyed by the caller.
+ * @deffunc int apr_bucket_shared_destroy(void *data)
*/
-APU_DECLARE(void *) apr_bucket_shared_destroy(void *data);
+APU_DECLARE(int) apr_bucket_shared_destroy(void *data);
/**
* Split a bucket into two at the given point, and adjust the refcount