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

[PATCH] dup function for svn_info_t

From: Chris Foote <cfoote_at_v21.me.uk>
Date: 2005-06-11 14:30:29 CEST

[LOG]

Add a function to duplicate the svn_info_t structure.

* subversion/include/svn_client.h
  (svn_info_t): Add note to update svn_info_dup when extending the struct.
  (svn_info_dup): New function to duplicate an svn_info_t.

* subversion/libsvn_client/info.c
  (svn_info_dup): Ditto.

--
Index: subversion/include/svn_client.h
===================================================================
--- subversion/include/svn_client.h (revision 15032)
+++ subversion/include/svn_client.h (working copy)
@@ -1975,6 +1975,9 @@
  */
 typedef struct svn_info_t
 {
+  /* IMPORTANT: If you extend this structure, check svn_info_dup() to see
+     if you need to extend that as well. */
+
   /** Where the item lives in the repository. */
   const char *URL;
@@ -2025,6 +2028,8 @@
   const char *prejfile;
   /** @} */
+  /* IMPORTANT: If you extend this structure, check svn_info_dup() to see
+     if you need to extend that as well. */
 } svn_info_t;
@@ -2043,6 +2048,15 @@
       apr_pool_t *pool);
 /**
+ * Return a duplicate of @a info, allocated in @a pool.  No part of the new
+ * structure will be shared with @a info.
+ *
+ * @since New in 1.3.
+ */
+svn_info_t *
+svn_info_dup(const svn_info_t *info, apr_pool_t *pool);
+
+/**
  * Invoke @a receiver with @a receiver_baton to return information
  * about @a path_or_url in @a revision.  The information returned is
  * system-generated metadata, not the sort of "property" metadata
Index: subversion/libsvn_client/info.c
===================================================================
--- subversion/libsvn_client/info.c (revision 15032)
+++ subversion/libsvn_client/info.c (working copy)
@@ -412,3 +412,40 @@
   return SVN_NO_ERROR;
 }
+
+
+svn_info_t *
+svn_info_dup (const svn_info_t *info, apr_pool_t *pool)
+{
+  svn_info_t *dupinfo = apr_pcalloc (pool, sizeof(*dupinfo));
+
+  /* Perform a trivial copy ... */
+  *dupinfo = *info;
+
+  /* ...and then re-copy stuff that needs to be duped into our pool. */
+  if (info->URL)
+    dupinfo->URL = apr_pstrdup (pool, info->URL);
+  if (info->repos_root_URL)
+    dupinfo->repos_root_URL = apr_pstrdup (pool, info->repos_root_URL);
+  if (info->repos_UUID)
+    dupinfo->repos_UUID = apr_pstrdup (pool, info->repos_UUID);
+  if (info->last_changed_author)
+    dupinfo->last_changed_author = apr_pstrdup (pool,
+                                                info->last_changed_author);
+  if (info->lock)
+    dupinfo->lock = svn_lock_dup (info->lock, pool);
+  if (info->copyfrom_url)
+    dupinfo->copyfrom_url = apr_pstrdup (pool, info->copyfrom_url);
+  if (info->checksum)
+    dupinfo->checksum = apr_pstrdup (pool, info->checksum);
+  if (info->conflict_old)
+    dupinfo->conflict_old = apr_pstrdup (pool, info->conflict_old);
+  if (info->conflict_new)
+    dupinfo->conflict_new = apr_pstrdup (pool, info->conflict_new);
+  if (info->conflict_wrk)
+    dupinfo->conflict_wrk = apr_pstrdup (pool, info->conflict_wrk);
+  if (info->prejfile)
+    dupinfo->prejfile = apr_pstrdup (pool, info->prejfile);
+
+  return dupinfo;
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Jun 11 14:31:25 2005

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.