httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <>
Subject Re: [PATCH] Extended API (EAPI)
Date Sat, 17 Apr 1999 00:11:01 GMT
This looks cool... 'cept it's kind of a huge change for 1.3.  I'd love
it in 1.4.  I haven't looked at the code, but I have one comment on

On Thu, 15 Apr 1999, Ralf S. Engelschall wrote:

>   | ap_ctx_set(buff->ctx, "CLIB", comp);

It's too bad you used "const char *" as the context identifier.  You're
adding extra cycles to the lookup of the context entry... consider
this instead:

    typedef struct {
	int index;	/* initially -1, assigned dynamically at run time */
	const char *name;
    } ctx_spec_t;

    /* used for declaring context specifiers in header files,
     * to be shared between modules */
    #define ap_declare_ctx_spec(name)	\
	extern struct ctx_spec_t ctx_spec_##name

    #define ap_define_ctx_spec(name)	\
	ctx_spec_t ctx_spec_##name = { -1, #name }

    #define ap_ctx_set(a,b,c)	\
	ap_ctx_set_core(a, &ctx_spec_##name, c)
    #define ap_ctx_get(a,b)	\
	ap_ctx_get_core(a, &ctx_spec_##name)

Then in a module:



    ap_ctx_set(buff->ctx, CLIB, comp);


    comp = (CLIB *)ap_ctx_get(buff->ctx, CLIB);

Then inside ap_ctx_get_core, for example:

    void *ap_ctx_get_core(your_ctx_type_here *foo, ctx_spec_t *spec)
	if (spec->index == -1) {
	    pick a new index for this specifier, we've never seen
	    it before
	    spec->index = new_index;
	return foo[spec->index];

Or something like that.

The linker does all the magic... and this should work with DSOs as well.


View raw message