Am Samstag, den 05.05.2007, 13:44 -0400 schrieb Tom Donovan:
> > static apr_pool_t *p_cur = NULL;
> > 
> > void xml2_set_current_pool(apr_pool_t * p)
> > {
> >     // Needed for free-logging
> >     p_cur = p;
> > }
> > 
> > static void xml2_child_init(apr_pool_t * p, server_rec * s)
> > {
> >     xml2_set_current_pool(p);
> > ....
> > 
> > In a function called from an external library I do
> > 
> > static void xml2_free(void *emem)
> > {
> >     ......
> > 
> >         ap_log_perror(APLOG_MARK, APLOG_DEBUG, 0, p_cur,
> >                 "xml2_free will free %x.", mem);
> >         free(mem);
> > }
> > 
> Two things:
> 
> 1.  You won't want to save the pool in a *static* p_cur if you have a 
> threaded Apache. All the threads will clobber each others' p_cur values.
> You might get away with this using Apache 1.3 (or with the prefork mpm).

This is just for debugging and will be removed, and I am on prefork.

> 2. The argument to xml2_free is named 'emem', but you pass 'mem' to 
> ap_log_perror.  Just a typo?  Is 'mem' related to 'emem' somehow?

Yes, but it is not of importance.

static void xml2_free(void *emem)
{
    if (!emem) {
        return;
    }
    void *mem = (char *) emem - sizeof(MARK);
    const char **mark = mem;
    if (*mark == MARK) {
        ap_log_perror(APLOG_MARK, APLOG_DEBUG, 0, p_cur,
                "xml2_free will free %x.", mem);
        free(mem);
    }
}

Actually I should write a test module to isolate the problem. Either
I'll find it doing that or I'll end up wih an apache bug.

Sincerely,
Joachim



Reply via email to