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

Re: Why passing a pool to a printf?

From: Greg Hudson <ghudson_at_MIT.EDU>
Date: 2004-05-18 03:49:52 CEST

On Mon, 2004-05-17 at 21:43, Nicolás Lichtmaier wrote:
> Why not creating and destroying a pool with each printf?

Creating and destroying a pool is moderately expensive.

Also, we don't like creating pools entirely from scratch. This way, the
printf implementation can allocate memory and not worry about cleaning
it up if it has to error out.

> Why cluttering the interface, requiring other functions to also
> include a pool?

Just about all of our public functions require a pool. Where they
don't, it usually means we screwed up. Perhaps it clutters the
interfaces, but it makes the implementations easier.

> And what about this:

> for(i=0 ; i<10000 ; i++)
> svn_cmdline_printf(pool, "file %s\n", files[i]);

> Won't this take lots of memory?

Yes. That's why we have this idiom documented in HACKING:

  subpool = svn_pool_create (pool);
  for (blah)
    {
      svn_pool_clear (subpool);
      stuff (..., subpool);
    }

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue May 18 03:50:21 2004

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.