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

Sub-pools for recursion

From: Julian Foad <julianfoad_at_btopenworld.com>
Date: 2003-11-28 14:46:04 CET

In copy_versioned_files (in subversion/libsvn_client/export.c) a sub-pool is created on entry and destroyed at the end of the function. I understand that this is the idiom used for recursive functions.

Within this function, "subpool" is used for most operations but "pool" is used for some. As far as I can tell, this is an accident and it is hard to spot because the accidental use of a parameter named "pool" is so familiar that it doesn't stand out.

I would like to suggest that in these cases we change the name of the super-pool in order to avoid this trap. Perhaps

  func (apr_pool_t *superpool)
  {
    apr_pool_t *subpool = svn_pool_create (superpool);

    foo (subpool);

    svn_pool_destroy (subpool);
  }

or

  func (apr_pool_t *superpool)
  {
    apr_pool_t *pool = svn_pool_create (superpool);

    foo (pool);

    svn_pool_destroy (pool);
  }

The former continually reminds the programmer that a sub-pool is in use, and changing to this style would be only a small patch; the latter is perhaps "cleaner" as it is more in line with other (non-recursive) code.

Comments?

- Julian

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Nov 28 14:42:57 2003

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.