Author: stefan2
Date: Thu Apr 12 20:08:50 2012
New Revision: 1325483

URL: http://svn.apache.org/viewvc?rev=1325483&view=rev
Log:
Replace the allocator creation & initialization boilerplate code
with a call to our new API.

* subversion/svn/main.c
* subversion/svnadmin/main.c
  (main): use new API
* subversion/svndumpfilter/main.c
  (main): use new API
* subversion/svnlook/main.c
  (main): use new API
* subversion/svnrdump/svnrdump.c
  (main): use new API
* subversion/svnserve/main.c
  (main): use new API
* subversion/svnsync/main.c
  (main): use new API
* subversion/svnversion/main.c
  (main): use new API

* subversion/tests/svn_test_main.c
  (main): use new API, be thread-safe (just in case)

* tools/client-side/svnmucc/svnmucc.c
  (init): use new API
* tools/dev/svnraisetreeconflict/main.c
  (main): use new API
* tools/server-side/svn-rep-sharing-stats.c
  (main): use new API

Modified:
    subversion/trunk/subversion/svn/main.c
    subversion/trunk/subversion/svnadmin/main.c
    subversion/trunk/subversion/svndumpfilter/main.c
    subversion/trunk/subversion/svnlook/main.c
    subversion/trunk/subversion/svnrdump/svnrdump.c
    subversion/trunk/subversion/svnserve/main.c
    subversion/trunk/subversion/svnsync/main.c
    subversion/trunk/subversion/svnversion/main.c
    subversion/trunk/subversion/tests/svn_test_main.c
    subversion/trunk/tools/client-side/svnmucc/svnmucc.c
    subversion/trunk/tools/dev/svnraisetreeconflict/main.c
    subversion/trunk/tools/server-side/svn-rep-sharing-stats.c

Modified: subversion/trunk/subversion/svn/main.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/main.c?rev=1325483&r1=1325482&r2=1325483&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/main.c (original)
+++ subversion/trunk/subversion/svn/main.c Thu Apr 12 20:08:50 2012
@@ -1542,7 +1542,6 @@ int
 main(int argc, const char *argv[])
 {
   svn_error_t *err;
-  apr_allocator_t *allocator;
   apr_pool_t *pool;
   int opt_id;
   apr_getopt_t *os;
@@ -1567,14 +1566,7 @@ main(int argc, const char *argv[])
   /* Create our top-level pool.  Use a separate mutexless allocator,
    * given this application is single threaded.
    */
-  if (apr_allocator_create(&allocator))
-    return EXIT_FAILURE;
-
-  apr_allocator_max_free_set(allocator, SVN_ALLOCATOR_RECOMMENDED_MAX_FREE);
-
-  pool = svn_pool_create_ex(NULL, allocator);
-  apr_allocator_owner_set(allocator, pool);
-
+  pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
   received_opts = apr_array_make(pool, SVN_OPT_MAX_OPTIONS, sizeof(int));
 
   /* Check library versions */

Modified: subversion/trunk/subversion/svnadmin/main.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svnadmin/main.c?rev=1325483&r1=1325482&r2=1325483&view=diff
==============================================================================
--- subversion/trunk/subversion/svnadmin/main.c (original)
+++ subversion/trunk/subversion/svnadmin/main.c Thu Apr 12 20:08:50 2012
@@ -1768,7 +1768,6 @@ main(int argc, const char *argv[])
 {
   svn_error_t *err;
   apr_status_t apr_err;
-  apr_allocator_t *allocator;
   apr_pool_t *pool;
 
   const svn_opt_subcommand_desc2_t *subcommand = NULL;
@@ -1785,13 +1784,7 @@ main(int argc, const char *argv[])
   /* Create our top-level pool.  Use a separate mutexless allocator,
    * given this application is single threaded.
    */
-  if (apr_allocator_create(&allocator))
-    return EXIT_FAILURE;
-
-  apr_allocator_max_free_set(allocator, SVN_ALLOCATOR_RECOMMENDED_MAX_FREE);
-
-  pool = svn_pool_create_ex(NULL, allocator);
-  apr_allocator_owner_set(allocator, pool);
+  pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
 
   received_opts = apr_array_make(pool, SVN_OPT_MAX_OPTIONS, sizeof(int));
 

Modified: subversion/trunk/subversion/svndumpfilter/main.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svndumpfilter/main.c?rev=1325483&r1=1325482&r2=1325483&view=diff
==============================================================================
--- subversion/trunk/subversion/svndumpfilter/main.c (original)
+++ subversion/trunk/subversion/svndumpfilter/main.c Thu Apr 12 20:08:50 2012
@@ -1262,7 +1262,6 @@ main(int argc, const char *argv[])
 {
   svn_error_t *err;
   apr_status_t apr_err;
-  apr_allocator_t *allocator;
   apr_pool_t *pool;
 
   const svn_opt_subcommand_desc2_t *subcommand = NULL;
@@ -1280,13 +1279,7 @@ main(int argc, const char *argv[])
   /* Create our top-level pool.  Use a separate mutexless allocator,
    * given this application is single threaded.
    */
-  if (apr_allocator_create(&allocator))
-   return EXIT_FAILURE;
-
-  apr_allocator_max_free_set(allocator, SVN_ALLOCATOR_RECOMMENDED_MAX_FREE);
-
-  pool = svn_pool_create_ex(NULL, allocator);
-  apr_allocator_owner_set(allocator, pool);
+  pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
 
   /* Check library versions */
   err = check_lib_versions();

Modified: subversion/trunk/subversion/svnlook/main.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svnlook/main.c?rev=1325483&r1=1325482&r2=1325483&view=diff
==============================================================================
--- subversion/trunk/subversion/svnlook/main.c (original)
+++ subversion/trunk/subversion/svnlook/main.c Thu Apr 12 20:08:50 2012
@@ -2251,7 +2251,6 @@ main(int argc, const char *argv[])
 {
   svn_error_t *err;
   apr_status_t apr_err;
-  apr_allocator_t *allocator;
   apr_pool_t *pool;
 
   const svn_opt_subcommand_desc2_t *subcommand = NULL;
@@ -2268,13 +2267,7 @@ main(int argc, const char *argv[])
   /* Create our top-level pool.  Use a separate mutexless allocator,
    * given this application is single threaded.
    */
-  if (apr_allocator_create(&allocator))
-    return EXIT_FAILURE;
-
-  apr_allocator_max_free_set(allocator, SVN_ALLOCATOR_RECOMMENDED_MAX_FREE);
-
-  pool = svn_pool_create_ex(NULL, allocator);
-  apr_allocator_owner_set(allocator, pool);
+  pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
 
   received_opts = apr_array_make(pool, SVN_OPT_MAX_OPTIONS, sizeof(int));
 

Modified: subversion/trunk/subversion/svnrdump/svnrdump.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svnrdump/svnrdump.c?rev=1325483&r1=1325482&r2=1325483&view=diff
==============================================================================
--- subversion/trunk/subversion/svnrdump/svnrdump.c (original)
+++ subversion/trunk/subversion/svnrdump/svnrdump.c Thu Apr 12 20:08:50 2012
@@ -694,7 +694,6 @@ main(int argc, const char **argv)
   apr_getopt_t *os;
   const char *first_arg;
   apr_array_header_t *received_opts;
-  apr_allocator_t *allocator;
   int i;
 
   if (svn_cmdline_init ("svnrdump", stderr) != EXIT_SUCCESS)
@@ -703,13 +702,7 @@ main(int argc, const char **argv)
   /* Create our top-level pool.  Use a separate mutexless allocator,
    * given this application is single threaded.
    */
-  if (apr_allocator_create(&allocator))
-    return EXIT_FAILURE;
-
-  apr_allocator_max_free_set(allocator, SVN_ALLOCATOR_RECOMMENDED_MAX_FREE);
-
-  pool = svn_pool_create_ex(NULL, allocator);
-  apr_allocator_owner_set(allocator, pool);
+  pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
 
   opt_baton = apr_pcalloc(pool, sizeof(*opt_baton));
   opt_baton->start_revision.kind = svn_opt_revision_unspecified;

Modified: subversion/trunk/subversion/svnserve/main.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svnserve/main.c?rev=1325483&r1=1325482&r2=1325483&view=diff
==============================================================================
--- subversion/trunk/subversion/svnserve/main.c (original)
+++ subversion/trunk/subversion/svnserve/main.c Thu Apr 12 20:08:50 2012
@@ -413,7 +413,6 @@ int main(int argc, const char *argv[])
   apr_sockaddr_t *sa;
   apr_pool_t *pool;
   apr_pool_t *connection_pool;
-  apr_allocator_t *allocator;
   svn_error_t *err;
   apr_getopt_t *os;
   int opt;
@@ -928,22 +927,12 @@ int main(int argc, const char *argv[])
         return ERROR_SUCCESS;
 #endif
 
-      /* If we are using fulltext caches etc. we will allocate many large
-         chunks of memory of various sizes outside the cache for those
-         fulltexts. Make sure we use the memory wisely: use an allocator
-         that causes memory fragments to be given back to the OS early. */
-
-      if (apr_allocator_create(&allocator))
-        return EXIT_FAILURE;
-
-      apr_allocator_max_free_set(allocator, 
SVN_ALLOCATOR_RECOMMENDED_MAX_FREE);
-
       /* Non-standard pool handling.  The main thread never blocks to join
          the connection threads so it cannot clean up after each one.  So
          separate pools that can be cleared at thread exit are used. */
 
-      connection_pool = svn_pool_create_ex(NULL, allocator);
-      apr_allocator_owner_set(allocator, connection_pool);
+      connection_pool
+          = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
 
       status = apr_socket_accept(&usock, sock, connection_pool);
       if (handling_mode == connection_mode_fork)

Modified: subversion/trunk/subversion/svnsync/main.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svnsync/main.c?rev=1325483&r1=1325482&r2=1325483&view=diff
==============================================================================
--- subversion/trunk/subversion/svnsync/main.c (original)
+++ subversion/trunk/subversion/svnsync/main.c Thu Apr 12 20:08:50 2012
@@ -1888,7 +1888,6 @@ main(int argc, const char *argv[])
   const char *password = NULL, *source_password = NULL, *sync_password = NULL;
   apr_array_header_t *config_options = NULL;
   const char *source_prop_encoding = NULL;
-  apr_allocator_t *allocator;
 
   if (svn_cmdline_init("svnsync", stderr) != EXIT_SUCCESS)
     {
@@ -1902,13 +1901,7 @@ main(int argc, const char *argv[])
   /* Create our top-level pool.  Use a separate mutexless allocator,
    * given this application is single threaded.
    */
-  if (apr_allocator_create(&allocator))
-    return EXIT_FAILURE;
-
-  apr_allocator_max_free_set(allocator, SVN_ALLOCATOR_RECOMMENDED_MAX_FREE);
-
-  pool = svn_pool_create_ex(NULL, allocator);
-  apr_allocator_owner_set(allocator, pool);
+  pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
 
   err = svn_ra_initialize(pool);
   if (err)

Modified: subversion/trunk/subversion/svnversion/main.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svnversion/main.c?rev=1325483&r1=1325482&r2=1325483&view=diff
==============================================================================
--- subversion/trunk/subversion/svnversion/main.c (original)
+++ subversion/trunk/subversion/svnversion/main.c Thu Apr 12 20:08:50 2012
@@ -122,7 +122,6 @@ main(int argc, const char *argv[])
 {
   const char *wc_path, *trail_url;
   const char *local_abspath;
-  apr_allocator_t *allocator;
   apr_pool_t *pool;
   svn_wc_revision_status_t *res;
   svn_boolean_t no_newline = FALSE, committed = FALSE;
@@ -150,13 +149,7 @@ main(int argc, const char *argv[])
   /* Create our top-level pool.  Use a separate mutexless allocator,
    * given this application is single threaded.
    */
-  if (apr_allocator_create(&allocator))
-    return EXIT_FAILURE;
-
-  apr_allocator_max_free_set(allocator, SVN_ALLOCATOR_RECOMMENDED_MAX_FREE);
-
-  pool = svn_pool_create_ex(NULL, allocator);
-  apr_allocator_owner_set(allocator, pool);
+  pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
 
   /* Check library versions */
   err = check_lib_versions();

Modified: subversion/trunk/subversion/tests/svn_test_main.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/svn_test_main.c?rev=1325483&r1=1325482&r2=1325483&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/svn_test_main.c (original)
+++ subversion/trunk/subversion/tests/svn_test_main.c Thu Apr 12 20:08:50 2012
@@ -345,7 +345,6 @@ main(int argc, const char *argv[])
   const char *prog_name;
   int i;
   svn_boolean_t got_error = FALSE;
-  apr_allocator_t *allocator;
   apr_pool_t *pool, *test_pool;
   svn_boolean_t ran_a_test = FALSE;
   svn_boolean_t list_mode = FALSE;
@@ -368,16 +367,10 @@ main(int argc, const char *argv[])
       exit(1);
     }
 
-  /* set up the global pool.  Use a separate mutexless allocator,
-   * given this application is single threaded.
+  /* set up the global pool.  Use a separate allocator to limit memory
+   * usage but make it thread-safe to allow for multi-threaded tests.
    */
-  if (apr_allocator_create(&allocator))
-    return EXIT_FAILURE;
-
-  apr_allocator_max_free_set(allocator, SVN_ALLOCATOR_RECOMMENDED_MAX_FREE);
-
-  pool = svn_pool_create_ex(NULL, allocator);
-  apr_allocator_owner_set(allocator, pool);
+  pool = apr_allocator_owner_get(svn_pool_create_allocator(TRUE));
 
   /* Remember the command line */
   test_argc = argc;

Modified: subversion/trunk/tools/client-side/svnmucc/svnmucc.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/tools/client-side/svnmucc/svnmucc.c?rev=1325483&r1=1325482&r2=1325483&view=diff
==============================================================================
--- subversion/trunk/tools/client-side/svnmucc/svnmucc.c (original)
+++ subversion/trunk/tools/client-side/svnmucc/svnmucc.c Thu Apr 12 20:08:50 
2012
@@ -69,8 +69,6 @@ static void handle_error(svn_error_t *er
 static apr_pool_t *
 init(const char *application)
 {
-  apr_allocator_t *allocator;
-  apr_pool_t *pool;
   svn_error_t *err;
   const svn_version_checklist_t checklist[] = {
     {"svn_client", svn_client_version},
@@ -81,19 +79,14 @@ init(const char *application)
 
   SVN_VERSION_DEFINE(my_version);
 
-  if (svn_cmdline_init(application, stderr)
-      || apr_allocator_create(&allocator))
+  if (svn_cmdline_init(application, stderr))
     exit(EXIT_FAILURE);
 
   err = svn_ver_check_list(&my_version, checklist);
   if (err)
     handle_error(err, NULL);
 
-  apr_allocator_max_free_set(allocator, SVN_ALLOCATOR_RECOMMENDED_MAX_FREE);
-  pool = svn_pool_create_ex(NULL, allocator);
-  apr_allocator_owner_set(allocator, pool);
-
-  return pool;
+  return apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
 }
 
 static svn_error_t *

Modified: subversion/trunk/tools/dev/svnraisetreeconflict/main.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/tools/dev/svnraisetreeconflict/main.c?rev=1325483&r1=1325482&r2=1325483&view=diff
==============================================================================
--- subversion/trunk/tools/dev/svnraisetreeconflict/main.c (original)
+++ subversion/trunk/tools/dev/svnraisetreeconflict/main.c Thu Apr 12 20:08:50 
2012
@@ -316,7 +316,6 @@ check_lib_versions(void)
 int
 main(int argc, const char *argv[])
 {
-  apr_allocator_t *allocator;
   apr_pool_t *pool;
   svn_error_t *err;
   apr_getopt_t *os;
@@ -336,13 +335,7 @@ main(int argc, const char *argv[])
   /* Create our top-level pool.  Use a separate mutexless allocator,
    * given this application is single threaded.
    */
-  if (apr_allocator_create(&allocator))
-    return EXIT_FAILURE;
-
-  apr_allocator_max_free_set(allocator, SVN_ALLOCATOR_RECOMMENDED_MAX_FREE);
-
-  pool = svn_pool_create_ex(NULL, allocator);
-  apr_allocator_owner_set(allocator, pool);
+  pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
 
   /* Check library versions */
   err = check_lib_versions();

Modified: subversion/trunk/tools/server-side/svn-rep-sharing-stats.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/tools/server-side/svn-rep-sharing-stats.c?rev=1325483&r1=1325482&r2=1325483&view=diff
==============================================================================
--- subversion/trunk/tools/server-side/svn-rep-sharing-stats.c (original)
+++ subversion/trunk/tools/server-side/svn-rep-sharing-stats.c Thu Apr 12 
20:08:50 2012
@@ -421,7 +421,6 @@ int
 main(int argc, const char *argv[])
 {
   const char *repos_path;
-  apr_allocator_t *allocator;
   apr_pool_t *pool;
   svn_boolean_t prop = FALSE, data = FALSE;
   svn_boolean_t quiet = FALSE;
@@ -446,13 +445,7 @@ main(int argc, const char *argv[])
   /* Create our top-level pool.  Use a separate mutexless allocator,
    * given this application is single threaded.
    */
-  if (apr_allocator_create(&allocator))
-    return EXIT_FAILURE;
-
-  apr_allocator_max_free_set(allocator, SVN_ALLOCATOR_RECOMMENDED_MAX_FREE);
-
-  pool = svn_pool_create_ex(NULL, allocator);
-  apr_allocator_owner_set(allocator, pool);
+  pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
 
   /* Check library versions */
   err = check_lib_versions();


Reply via email to