jwoolley 01/08/07 22:58:15
Modified: . CHANGES
buckets apr_buckets_eos.c apr_buckets_file.c
apr_buckets_flush.c apr_buckets_heap.c
apr_buckets_mmap.c apr_buckets_pipe.c
apr_buckets_pool.c apr_buckets_simple.c
apr_buckets_socket.c
include apr_buckets.h
Log:
Move the free function pointer out of the apr_bucket_type_t and into the
apr_bucket struct itself, because the free() function operates on the
apr_bucket and not the bucket's private data [which might change if we morph].
Revision Changes Path
1.28 +2 -2 apr-util/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/apr-util/CHANGES,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -u -r1.27 -r1.28
--- CHANGES 2001/08/07 23:02:40 1.27
+++ CHANGES 2001/08/08 05:58:15 1.28
@@ -3,12 +3,12 @@
*) Added apr_xml_parse_file() routine and a testxml program.
[Ian Holsman <[EMAIL PROTECTED]>]
- *) Extend apr_bucket_type_t to add a pointer to a function used
+ *) Extend apr_bucket struct to add a pointer to a function used
to free the bucket. This change enables custom buckets to
completely specify how they are to be allocated and freed.
Before this change, custom buckets were required to use the
same memory allocation scheme as the standard APR buckets.
- [Saeid Sakhitab, Bill Stoddard]
+ [Saeid Sakhitab, Bill Stoddard, Cliff Woolley, Roy Fielding]
*) Install Expat when installing APR-util. [Justin Erenkrantz]
1.28 +1 -1 apr-util/buckets/apr_buckets_eos.c
Index: apr_buckets_eos.c
===================================================================
RCS file: /home/cvs/apr-util/buckets/apr_buckets_eos.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -u -r1.27 -r1.28
--- apr_buckets_eos.c 2001/08/03 14:21:52 1.27
+++ apr_buckets_eos.c 2001/08/08 05:58:15 1.28
@@ -84,13 +84,13 @@
apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));
APR_BUCKET_INIT(b);
+ b->free = free;
return apr_bucket_eos_make(b);
}
APU_DECLARE_DATA const apr_bucket_type_t apr_bucket_type_eos = {
"EOS", 5,
apr_bucket_destroy_noop,
- free,
eos_read,
apr_bucket_setaside_noop,
apr_bucket_split_notimpl,
1.53 +1 -1 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.52
retrieving revision 1.53
diff -u -d -u -r1.52 -r1.53
--- apr_buckets_file.c 2001/08/03 14:21:52 1.52
+++ apr_buckets_file.c 2001/08/08 05:58:15 1.53
@@ -227,6 +227,7 @@
apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));
APR_BUCKET_INIT(b);
+ b->free = free;
return apr_bucket_file_make(b, fd, offset, len, p);
}
@@ -262,7 +263,6 @@
APU_DECLARE_DATA const apr_bucket_type_t apr_bucket_type_file = {
"FILE", 5,
file_destroy,
- free,
file_read,
file_setaside,
apr_bucket_shared_split,
1.20 +1 -1 apr-util/buckets/apr_buckets_flush.c
Index: apr_buckets_flush.c
===================================================================
RCS file: /home/cvs/apr-util/buckets/apr_buckets_flush.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -u -r1.19 -r1.20
--- apr_buckets_flush.c 2001/08/03 14:21:52 1.19
+++ apr_buckets_flush.c 2001/08/08 05:58:15 1.20
@@ -84,13 +84,13 @@
apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));
APR_BUCKET_INIT(b);
+ b->free = free;
return apr_bucket_flush_make(b);
}
APU_DECLARE_DATA const apr_bucket_type_t apr_bucket_type_flush = {
"FLUSH", 5,
apr_bucket_destroy_noop,
- free,
flush_read,
apr_bucket_setaside_noop,
apr_bucket_split_notimpl,
1.36 +1 -1 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.35
retrieving revision 1.36
diff -u -d -u -r1.35 -r1.36
--- apr_buckets_heap.c 2001/08/03 14:21:52 1.35
+++ apr_buckets_heap.c 2001/08/08 05:58:15 1.36
@@ -120,13 +120,13 @@
apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));
APR_BUCKET_INIT(b);
+ b->free = free;
return apr_bucket_heap_make(b, buf, length, copy, w);
}
APU_DECLARE_DATA const apr_bucket_type_t apr_bucket_type_heap = {
"HEAP", 5,
heap_destroy,
- free,
heap_read,
apr_bucket_setaside_noop,
apr_bucket_shared_split,
1.41 +1 -1 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.40
retrieving revision 1.41
diff -u -d -u -r1.40 -r1.41
--- apr_buckets_mmap.c 2001/08/03 14:21:52 1.40
+++ apr_buckets_mmap.c 2001/08/08 05:58:15 1.41
@@ -113,6 +113,7 @@
apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));
APR_BUCKET_INIT(b);
+ b->free = free;
return apr_bucket_mmap_make(b, mm, start, length);
}
@@ -144,7 +145,6 @@
APU_DECLARE_DATA const apr_bucket_type_t apr_bucket_type_mmap = {
"MMAP", 5,
mmap_destroy,
- free,
mmap_read,
mmap_setaside,
apr_bucket_shared_split,
1.39 +1 -1 apr-util/buckets/apr_buckets_pipe.c
Index: apr_buckets_pipe.c
===================================================================
RCS file: /home/cvs/apr-util/buckets/apr_buckets_pipe.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -u -r1.38 -r1.39
--- apr_buckets_pipe.c 2001/08/03 14:21:52 1.38
+++ apr_buckets_pipe.c 2001/08/08 05:58:15 1.39
@@ -147,13 +147,13 @@
apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));
APR_BUCKET_INIT(b);
+ b->free = free;
return apr_bucket_pipe_make(b, p);
}
APU_DECLARE_DATA const apr_bucket_type_t apr_bucket_type_pipe = {
"PIPE", 5,
apr_bucket_destroy_noop,
- free,
pipe_read,
apr_bucket_setaside_notimpl,
apr_bucket_split_notimpl,
1.22 +1 -1 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.21
retrieving revision 1.22
diff -u -d -u -r1.21 -r1.22
--- apr_buckets_pool.c 2001/08/03 14:21:52 1.21
+++ apr_buckets_pool.c 2001/08/08 05:58:15 1.22
@@ -165,13 +165,13 @@
apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));
APR_BUCKET_INIT(b);
+ b->free = free;
return apr_bucket_pool_make(b, buf, length, pool);
}
APU_DECLARE_DATA const apr_bucket_type_t apr_bucket_type_pool = {
"POOL", 5,
pool_destroy,
- free,
pool_read,
apr_bucket_setaside_noop,
apr_bucket_shared_split,
1.32 +2 -2 apr-util/buckets/apr_buckets_simple.c
Index: apr_buckets_simple.c
===================================================================
RCS file: /home/cvs/apr-util/buckets/apr_buckets_simple.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -u -r1.31 -r1.32
--- apr_buckets_simple.c 2001/08/03 14:21:52 1.31
+++ apr_buckets_simple.c 2001/08/08 05:58:15 1.32
@@ -115,6 +115,7 @@
apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));
APR_BUCKET_INIT(b);
+ b->free = free;
return apr_bucket_immortal_make(b, buf, length);
}
@@ -152,13 +153,13 @@
apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));
APR_BUCKET_INIT(b);
+ b->free = free;
return apr_bucket_transient_make(b, buf, length);
}
const apr_bucket_type_t apr_bucket_type_immortal = {
"IMMORTAL", 5,
apr_bucket_destroy_noop,
- free,
simple_read,
apr_bucket_setaside_noop,
apr_bucket_simple_split,
@@ -168,7 +169,6 @@
APU_DECLARE_DATA const apr_bucket_type_t apr_bucket_type_transient = {
"TRANSIENT", 5,
apr_bucket_destroy_noop,
- free,
simple_read,
transient_setaside,
apr_bucket_simple_split,
1.28 +1 -1 apr-util/buckets/apr_buckets_socket.c
Index: apr_buckets_socket.c
===================================================================
RCS file: /home/cvs/apr-util/buckets/apr_buckets_socket.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -u -r1.27 -r1.28
--- apr_buckets_socket.c 2001/08/03 14:21:52 1.27
+++ apr_buckets_socket.c 2001/08/08 05:58:15 1.28
@@ -142,13 +142,13 @@
apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));
APR_BUCKET_INIT(b);
+ b->free = free;
return apr_bucket_socket_make(b, p);
}
APU_DECLARE_DATA const apr_bucket_type_t apr_bucket_type_socket = {
"SOCKET", 5,
apr_bucket_destroy_noop,
- free,
socket_read,
apr_bucket_setaside_notimpl,
apr_bucket_split_notimpl,
1.105 +9 -10 apr-util/include/apr_buckets.h
Index: apr_buckets.h
===================================================================
RCS file: /home/cvs/apr-util/include/apr_buckets.h,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -d -u -r1.104 -r1.105
--- apr_buckets.h 2001/08/03 14:21:52 1.104
+++ apr_buckets.h 2001/08/08 05:58:15 1.105
@@ -164,15 +164,6 @@
void (*destroy)(void *data);
/**
- * Pointer to function used to free the bucket. This function should
- * always be defined and it should be consistent with the memory
- * function used to allocate the bucket. For example, if malloc() is
- * used to allocate the bucket, this pointer should point to free().
- * @param e Pointer to the bucket being freed
- */
- void (*free)(void *e);
-
- /**
* Read the data from the bucket. This is guaranteed to be implemented
* for all bucket types.
* @param b The bucket to read from
@@ -255,6 +246,14 @@
apr_off_t start;
/** type-dependent data hangs off this pointer */
void *data;
+ /**
+ * Pointer to function used to free the bucket. This function should
+ * always be defined and it should be consistent with the memory
+ * function used to allocate the bucket. For example, if malloc() is
+ * used to allocate the bucket, this pointer should point to free().
+ * @param e Pointer to the bucket being freed
+ */
+ void (*free)(void *e);
};
/** A list of buckets */
@@ -787,7 +786,7 @@
*/
#define apr_bucket_destroy(e) do { \
(e)->type->destroy((e)->data);
\
- (e)->type->free(e); \
+ (e)->free(e);
\
} while (0)
/**