You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2010/05/03 14:19:07 UTC

svn commit: r940429 - in /subversion/trunk/subversion: include/svn_subst.h libsvn_subr/subst.c

Author: stsp
Date: Mon May  3 12:19:07 2010
New Revision: 940429

URL: http://svn.apache.org/viewvc?rev=940429&view=rev
Log:
Revert additional pool lifetime requirements introduced in r937275.

* subversion/include/svn_subst.h,
  subversion/libsvn_subr/subst.c
  (svn_subst_stream_translated): Copy EOL_STR and KEYWORDS into
   RESULT_POOL to make sure they have sufficient lifetime, and remove
   pool lifetime restrictions for EOL_STR and KEYWORDS from docstring.

Suggested by: julianfoad
              gstein

Modified:
    subversion/trunk/subversion/include/svn_subst.h
    subversion/trunk/subversion/libsvn_subr/subst.c

Modified: subversion/trunk/subversion/include/svn_subst.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_subst.h?rev=940429&r1=940428&r2=940429&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_subst.h (original)
+++ subversion/trunk/subversion/include/svn_subst.h Mon May  3 12:19:07 2010
@@ -302,8 +302,6 @@ svn_subst_translate_stream(svn_stream_t 
  * Recognized line endings are: "\n", "\r", and "\r\n".
  *
  * The stream returned is allocated in @a result_pool.
- * @a eol_str and @a keywords are expected to be allocated in a pool
- * with sufficient lifetime for use by the stream.
  *
  * If the inner stream implements resetting via svn_stream_reset(),
  * or marking and seeking via svn_stream_mark() and svn_stream_seek(),

Modified: subversion/trunk/subversion/libsvn_subr/subst.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/subst.c?rev=940429&r1=940428&r2=940429&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/subst.c (original)
+++ subversion/trunk/subversion/libsvn_subr/subst.c Mon May  3 12:19:07 2010
@@ -1272,6 +1272,39 @@ svn_subst_stream_translated(svn_stream_t
     = apr_palloc(result_pool, sizeof(*baton));
   svn_stream_t *s = svn_stream_create(baton, result_pool);
 
+  /* Make sure EOL_STR and KEYWORDS are allocated in RESULT_POOL
+     so they have the same lifetime as the stream. */
+  if (eol_str)
+    eol_str = apr_pstrdup(result_pool, eol_str);
+  if (keywords)
+    {
+      if (apr_hash_count(keywords) == 0)
+        keywords = NULL;
+      else
+        {
+          /* deep copy the hash to make sure it's allocated in RESULT_POOL */
+          apr_hash_t *copy = apr_hash_make(result_pool);
+          apr_hash_index_t *hi;
+          apr_pool_t *subpool;
+
+          subpool = svn_pool_create(result_pool);
+          for (hi = apr_hash_first(subpool, keywords);
+               hi; hi = apr_hash_next(hi))
+            {
+              const void *key;
+              void *val;
+
+              apr_hash_this(hi, &key, NULL, &val);
+              apr_hash_set(copy, apr_pstrdup(result_pool, key),
+                           APR_HASH_KEY_STRING,
+                           svn_string_dup(val, result_pool));
+            }
+          svn_pool_destroy(subpool);
+
+          keywords = copy;
+        }
+    }
+
   /* Setup the baton fields */
   baton->stream = stream;
   baton->in_baton