httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Stein <>
Subject Re: mod_speling mem usage on large directories
Date Fri, 22 Jan 1999 23:11:58 GMT
Eric Prud'hommeaux wrote:
> ...
> The problem is that mod_speling works by ap_strcating each entry onto
> the big filelist that is the http body on the 303. The strcat looks
> something like this:
>   t = ap_strcat(pool, t, current entry);
> This means that the original pointer is lost and never freed (until
> the pool is cleared).

Yup. Quite icky indeed.

I ran into the same situation in mod_dav, where I was preparing response
bodies. The responses, for all intents and purposes, are unbounded.
Anyhow, I recognized the concat problem that you mentioned and avoided

> ...
> My plan was to take care of the bulk of the problem (assuming
> fortuitous memory management) by using ap_realloc or ap_free. Since
> these functions don't exist, I'm writing to you with a bug report,
> rather than a patch. Sorry.

In mod_dav, I maintain a linked list of text segments. Here are the two
structures that I use:

typedef struct dav_text
    const char *text;
    struct dav_text *next;
} dav_text;

typedef struct
    dav_text *first;
    dav_text *last;
} dav_text_header;

The header is used during construction. Once the complete text is built,
then I just return header->first. The header is used to avoid running
the list each time something is appended; instead, it just links the new
dav_text item onto header->last and moves header->last forward.

When I actually go to output the text, I use a simple block of code like

for ( p = the_text_ptr; p; p = p->next )
  ar_rputs(p->text, r);

If you wish, please feel free to grab a copy of mod_dav and reuse the
structures and functions (there is one utility function in dav_util.c).

I might also request the Apache Group to consider a similar system for
libap or somesuch. Please, steal my dav_text code :-)


Greg Stein,

View raw message