On 10/13/05, Stefan Küng <tortoisesvn@gmail.com> wrote:
> Garrett Rooney wrote:
> > One comment that occurred to me as I read over this patch...
> >
> >
> >>+typedef struct win_xlate_t {
> >>+ apr_pool_t *pool;
> >>+ char *frompage;
> >>+ char *topage;
> >>+ char *sbcs_table;
> >>+} win_xlate_t;
> >
> >
> > Storing a pool in this structure throws up a red flag for me...
> >
> [snip]
> > And this is why. Won't we be allocating that buffer every time we
> > call this function, without ever clearing that pool? If we really
> > need to allocate that buffer each time, we also need to be sure we're
> > clearing that pool when we're done with it, which means that
> > convset->pool really should be a specially created subpool just for
> > that purpose.
>
> Good point. Revised patch attached.
This solves the problem, but we generally try to avoid using
malloc/free unless we absolutely have to (i.e. we're passing something
to third party code that expects to free it later, or we get something
from third party code that it expects us to free). To do this with
pools you should be storing a subpool in win_xlate_t, use that to
apr_palloc your memory, then clear the pool when you're done with the
memory.
-garrett
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Oct 13 19:40:35 2005