httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rodent of Unusual Size <Ken.C...@Golux.Com>
Subject Re: Context types in apr
Date Thu, 29 Apr 1999 21:05:17 GMT
Ryan Bloom wrote:
> 
> Any thoughts/comments?  I can always remove the context structures
> if the group thinks they aren't needed.

I'm in favour of this.  Since the contexts will need to be created
somehow, I envision something like the following (pseudocode) being
possible:

apr_context_t *ctx;
apr_context_t *subctx;
typedef struct {
    int size;
    char *ptr;
} foo;
foo *memp;

ctx = apr_create_context(NULL);  /* create a 'top-level' context */
subctx = apr_create_context(ctx);/* a 'sub-pool'-like thing */
	:
fp = apr_file_open(subctx, ...);
memp = apr_alloc(context, sizeof(foo));
memp->size = 5;
memp->ptr = apr_alloc(context, memp->size);
strcpy(memp->ptr, "1234");
status = apr_set_uservar(context, memp)
	:
memp = apr_get_uservar(context);
	:
apr_destroy_context(ctx);

It's very easy to think of these contexts as though they were
pools, though they're actually pools-plus.

I see the context pointer being passed to *all* APR functions,
whether the functions need it or not, for two reasons:

1. Uniformity of semantics
2. Something the function itself calls may need it, now or later
-- 
#ken    P-)}

Ken Coar                    <http://Web.Golux.Com/coar/>
Apache Software Foundation  <http://www.apache.org/>
"Apache Server for Dummies" <http://Web.Golux.Com/coar/ASFD/>

Mime
View raw message