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

[PATCH] Avoid allocating memory to extract basename using svn_relpath_basename

From: vijayaguru <vijay_at_collab.net>
Date: Mon, 04 Oct 2010 17:52:27 +0530

Hi,

  From svn_relpath_basename documentation, if pool is NULL, it simply
returns a pointer to the string without allocating additional memory.
Pass NULL pointer to svn_relpath_basename wherever the returned basename
need not be persistent. It could save few bytes of memory.

[[[
  Log:
  Pass NULL pointer to svn_relpath_basename wherever the returned
  basename need not be allocated in pool.
            
  * subversion/mod_dav_svn/reports/update.c
    (absent_helper, upd_delete_entry)
  * subversion/libsvn_wc/update_editor.c
    (delete_entry)
  * subversion/svnlook/main.c
    (print_tree)
  * subversion/libsvn_client/repos_diff.c
    (absent_directory)
  * subversion/libsvn_ra_neon/commit.c
    (commit_delete_entry)
  * subversion/libsvn_ra_serf/commit.c
    (checkout_dir)
  * subversion/libsvn_repos/node_tree.c
    (add_open_helper)
    
        Pass NULL pointer to svn_relpath_basename wherever the returned
        basename need not be persistent.

Patch by: Vijayaguru G <vijay_at_collab.net>
Suggested by: Kameshj
 
]]]

Thanks & Regards,
Vijayaguru

Index: subversion/mod_dav_svn/reports/update.c
===================================================================
--- subversion/mod_dav_svn/reports/update.c (revision 1002949)
+++ subversion/mod_dav_svn/reports/update.c (working copy)
@@ -250,7 +250,7 @@
                "<S:absent-%s name=\"%s\"/>" DEBUG_CR,
                DIR_OR_FILE(is_dir),
                apr_xml_quote_string(pool,
- svn_relpath_basename(path, pool),
+ svn_relpath_basename(path, NULL),
                                     1)));
     }
 
@@ -589,7 +589,7 @@
 {
   item_baton_t *parent = parent_baton;
   const char *qname = apr_xml_quote_string(pool,
- svn_relpath_basename(path, pool),
+ svn_relpath_basename(path, NULL),
                                            1);
   return dav_svn__brigade_printf(parent->uc->bb, parent->uc->output,
                                  "<S:delete-entry name=\"%s\"/>" DEBUG_CR,
Index: subversion/libsvn_wc/update_editor.c
===================================================================
--- subversion/libsvn_wc/update_editor.c (revision 1002949)
+++ subversion/libsvn_wc/update_editor.c (working copy)
@@ -2116,7 +2116,7 @@
              apr_pool_t *pool)
 {
   struct dir_baton *pb = parent_baton;
- const char *base = svn_relpath_basename(path, pool);
+ const char *base = svn_relpath_basename(path, NULL);
   const char *local_abspath;
   const char *their_relpath;
 
Index: subversion/svnlook/main.c
===================================================================
--- subversion/svnlook/main.c (revision 1002949)
+++ subversion/svnlook/main.c (working copy)
@@ -1204,7 +1204,7 @@
   else if (*path == '/')
     name = svn_uri_basename(path, pool);
   else
- name = svn_relpath_basename(path, pool);
+ name = svn_relpath_basename(path, NULL);
 
   if (svn_path_is_empty(name))
     name = "/"; /* basename of '/' is "" */
Index: subversion/libsvn_client/repos_diff.c
===================================================================
--- subversion/libsvn_client/repos_diff.c (revision 1002949)
+++ subversion/libsvn_client/repos_diff.c (working copy)
@@ -1244,7 +1244,7 @@
       svn_wc_notify_t *notify
         = svn_wc_create_notify(svn_dirent_join(pb->wcpath,
                                                svn_relpath_basename(path,
- pool),
+ NULL),
                                                pool),
                                svn_wc_notify_skip, pool);
       notify->kind = svn_node_dir;
Index: subversion/libsvn_ra_neon/commit.c
===================================================================
--- subversion/libsvn_ra_neon/commit.c (revision 1002949)
+++ subversion/libsvn_ra_neon/commit.c (working copy)
@@ -701,7 +701,7 @@
                                          apr_pool_t *pool)
 {
   resource_baton_t *parent = parent_baton;
- const char *name = svn_relpath_basename(path, pool);
+ const char *name = svn_relpath_basename(path, NULL);
   apr_hash_t *extra_headers = NULL;
   const char *child;
   int code;
Index: subversion/libsvn_ra_serf/commit.c
===================================================================
--- subversion/libsvn_ra_serf/commit.c (revision 1002949)
+++ subversion/libsvn_ra_serf/commit.c (working copy)
@@ -380,7 +380,7 @@
           dir->checkout->activity_url_len = dir->commit->activity_url_len;
           dir->checkout->resource_url =
             svn_path_url_add_component2(dir->parent_dir->checkout->resource_url,
- svn_relpath_basename(dir->name, dir->pool),
+ svn_relpath_basename(dir->name, NULL),
                                         dir->pool);
 
           apr_hash_set(dir->commit->copied_entries,
Index: subversion/libsvn_repos/node_tree.c
===================================================================
--- subversion/libsvn_repos/node_tree.c (revision 1002949)
+++ subversion/libsvn_repos/node_tree.c (working copy)
@@ -268,7 +268,7 @@
   nb->parent_baton = pb;
 
   /* Create and populate the node. */
- nb->node = create_child_node(pb->node, svn_relpath_basename(path, pool),
+ nb->node = create_child_node(pb->node, svn_relpath_basename(path, NULL),
                                eb->node_pool);
   nb->node->kind = kind;
   nb->node->action = action;
Received on 2010-10-04 14:24:00 CEST

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.