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

Re: [PATCH] Don't ignore multiple --target switches

From: C. Michael Pilato <cmpilato_at_collab.net>
Date: 2006-05-31 23:06:11 CEST

Hyrum K. Wright wrote:
> This patch fixes a bug where multiple --target switches fail silently
> for all but the final one. Instead, this patch concatenates all targets
> specified by multiple --target switches into one array.
> Coincidentally, this patch also fixes a memory leak, since we were just
> dropping the previous list of targets when we encountered additional
> --target switches.

Eh, we're still leaking memory with this patch because apr_array_append()
doesn't reuse either of the arrays it's given as input. So it takes array A
and B and makes a new C (wasting both A and B). If a third --targets comes
along, it'll waste another pair of arrays. And so on. But we're only
talking about an amount of memory proportional to the number of times
--targets shows up as an option, and not alot of memory at that.

Still, if you know you're going to be wasting memory anyway, you can
simplify the code like so:

   if (! opt_state.targets)
     opt_state.targets = apr_array_make(pool, 8, sizeof(const char *));
   opt_state.targets = apr_array_append(pool, opt_state.targets,
                                                          "\n\r", TRUE,

C. Michael Pilato <cmpilato@collab.net>
CollabNet   <>   www.collab.net   <>   Distributed Development On Demand

Received on Wed May 31 23:08:01 2006

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