[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH]: Trying to get rid of iconv dependency on windows

From: Garrett Rooney <rooneg_at_electricjellyfish.net>
Date: 2005-10-13 19:38:36 CEST

On 10/13/05, Stefan Kng <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

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.