Author: stefan2
Date: Sat Jan 17 21:54:11 2015
New Revision: 1652681
URL: http://svn.apache.org/r1652681
Log:
Tighten memory usage in FSX' svn_fs_dir_entries implementation.
* subversion/libsvn_fs_x/tree.c
(x_dir_entries): Introduce a SCRATCH_POOL and fetch the directory in its
FSX-private format using that pool. Return a deep copy
of it in the FS API format. Once the function returns,
the caller-provided pool will contain no lingering
internal / temporary data structures.
Modified:
subversion/trunk/subversion/libsvn_fs_x/tree.c
Modified: subversion/trunk/subversion/libsvn_fs_x/tree.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/tree.c?rev=1652681&r1=1652680&r2=1652681&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/tree.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/tree.c Sat Jan 17 21:54:11 2015
@@ -2365,10 +2365,11 @@ x_dir_entries(apr_hash_t **table_p,
apr_array_header_t *table;
int i;
svn_fs_x__id_context_t *context = NULL;
+ apr_pool_t *scratch_pool = svn_pool_create(pool);
/* Get the entries for this path in the caller's pool. */
- SVN_ERR(get_dag(&node, root, path, pool));
- SVN_ERR(svn_fs_x__dag_dir_entries(&table, node, pool));
+ SVN_ERR(get_dag(&node, root, path, scratch_pool));
+ SVN_ERR(svn_fs_x__dag_dir_entries(&table, node, scratch_pool));
if (table->nelts)
context = svn_fs_x__id_create_context(root->fs, pool);
@@ -2378,16 +2379,19 @@ x_dir_entries(apr_hash_t **table_p,
{
svn_fs_x__dirent_t *entry
= APR_ARRAY_IDX(table, i, svn_fs_x__dirent_t *);
+ apr_size_t len = strlen(entry->name);
svn_fs_dirent_t *api_dirent = apr_pcalloc(pool, sizeof(*api_dirent));
- api_dirent->name = entry->name;
+ api_dirent->name = apr_pstrmemdup(pool, entry->name, len);
api_dirent->kind = entry->kind;
api_dirent->id = svn_fs_x__id_create(context, &entry->id, pool);
- svn_hash_sets(hash, api_dirent->name, api_dirent);
+ apr_hash_set(hash, api_dirent->name, len, api_dirent);
}
*table_p = hash;
+ svn_pool_destroy(scratch_pool);
+
return SVN_NO_ERROR;
}