From: Christophe Jaillet
struct dummy_state {
+ Example code to maintain filter state
struct dummy_state {
apr_bucket_brigade *tmpbb;
int filter_state;
- ....
+ ...
};
apr_status_t dummy_filter(ap_filter_t *f, apr_bucket_brigade *bb)
@@ -321,7 +321,7 @@ apr_status_t dummy_filter(ap_filter_t *f, apr_bucket_brigade *bb)
/* First invocation for this response: initialise state structure.
*/
- f->ctx = state = apr_palloc(sizeof *state, f->r->pool);
+ f->ctx = state = apr_palloc(f->r->pool, sizeof *state);
state->tmpbb = apr_brigade_create(f->r->pool, f->c->bucket_alloc);
state->filter_state = ...;
diff --git a/docs/manual/developer/output-filters.xml b/docs/manual/developer/output-filters.xml
index ce9a9689146..afa61da162f 100644
--- a/docs/manual/developer/output-filters.xml
+++ b/docs/manual/developer/output-filters.xml
@@ -309,12 +309,12 @@ while ((e = APR_BRIGADE_FIRST(bb)) != APR_BRIGADE_SENTINEL(bb)) {
a new brigade per invocation as described in the Brigade structure section.
- Example code to maintain filter state
-
+ Example code to maintain filter state
+
struct dummy_state {
apr_bucket_brigade *tmpbb;
int filter_state;
- ....
+ ...
};
apr_status_t dummy_filter(ap_filter_t *f, apr_bucket_brigade *bb)
@@ -327,7 +327,7 @@ apr_status_t dummy_filter(ap_filter_t *f, apr_bucket_brigade *bb)
/* First invocation for this response: initialise state structure.
*/
- f->ctx = state = apr_palloc(sizeof *state, f->r->pool);
+ f->ctx = state = apr_palloc(f->r->pool, sizeof *state);
state->tmpbb = apr_brigade_create(f->r->pool, f->c->bucket_alloc);
state->filter_state = ...;