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

[PATCH] Eliminate dag.c's NODE_POOL, step 1.

From: Daniel Shahaf <danielsh_at_elego.de>
Date: Sat, 24 Mar 2012 17:25:28 +0200

[[[
FSFS: Eliminate the DAG API's NODE_POOL, step 1.

This makes the dag_node_t struct track its own lifetime, rather than
depend on callers to provide a convenient pool to allocate parts of
itself in. Subsequent revisions will remove the now-unused POOL
parameter to get_node_revision() and update pool usage up the call tree.

* subversion/libsvn_fs_fs/dag.c
  (dag_node_t): Grow NODE_POOL member.
  (get_node_revision): Use NODE_POOL instead of the caller's pool,
    making the latter unused.
  (svn_fs_fs__dag_get_node, svn_fs_fs__dag_dup):
    Set NODE_POOL when allocating or reconstructing a dag_node_t.
]]]

[[[
Index: subversion/libsvn_fs_fs/dag.c
===================================================================
--- subversion/libsvn_fs_fs/dag.c (revision 1304811)
+++ subversion/libsvn_fs_fs/dag.c (working copy)
@@ -70,6 +70,9 @@ struct dag_node_t
      things for you. */
   node_revision_t *node_revision;
 
+ /* The pool to allocate NODE_REVISION in. */
+ apr_pool_t *node_pool;
+
   /* the path at which this node was created. */
   const char *created_path;
 };
@@ -151,15 +154,16 @@ copy_node_revision(node_revision_t *noderev,
 static svn_error_t *
 get_node_revision(node_revision_t **noderev_p,
                   dag_node_t *node,
- apr_pool_t *pool)
+ apr_pool_t *pool /* unused */)
 {
   node_revision_t *noderev;
+ SVN_ERR_ASSERT(node->node_pool); /* scalpel */
 
   /* If we've already got a copy, there's no need to read it in. */
   if (! node->node_revision)
     {
       SVN_ERR(svn_fs_fs__get_node_revision(&noderev, node->fs,
- node->id, pool));
+ node->id, node->node_pool));
       node->node_revision = noderev;
     }
 
@@ -190,6 +195,7 @@ svn_fs_fs__dag_get_node(dag_node_t **node,
   new_node->id = svn_fs_fs__id_copy(id, pool);
 
   /* Grab the contents so we can inspect the node's kind and created path. */
+ new_node->node_pool = pool;
   SVN_ERR(get_node_revision(&noderev, new_node, pool));
 
   /* Initialize the KIND and CREATED_PATH attributes */
@@ -1066,6 +1072,8 @@ svn_fs_fs__dag_dup(const dag_node_t *node,
       new_node->node_revision->is_fresh_txn_root =
           node->node_revision->is_fresh_txn_root;
     }
+ new_node->node_pool = pool;
+
   return new_node;
 }
 
@@ -1092,6 +1100,10 @@ svn_fs_fs__dag_serialize(char **data,
     svn_temp_serializer__set_null(context,
                                   (const void * const *)&node->node_revision);
 
+ /* The deserializer will use its own pool. */
+ svn_temp_serializer__set_null(context,
+ (const void * const *)&node->node_pool);
+
   /* serialize other sub-structures */
   svn_fs_fs__id_serialize(context, (const svn_fs_id_t **)&node->id);
   svn_fs_fs__id_serialize(context, &node->fresh_root_predecessor_id);
@@ -1124,6 +1136,7 @@ svn_fs_fs__dag_deserialize(void **out,
   svn_fs_fs__id_deserialize(node,
                             (svn_fs_id_t **)&node->fresh_root_predecessor_id);
   svn_fs_fs__noderev_deserialize(node, &node->node_revision);
+ node->node_pool = pool;
 
   svn_temp_deserializer__resolve(node, (void**)&node->created_path);
 
]]]
Received on 2012-03-24 16:26:15 CET

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.