subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r1660659 - in /subversion/trunk/subversion: include/private/svn_sqlite.h libsvn_subr/sqlite.c libsvn_wc/wc_db_util.c tests/libsvn_subr/sqlite-test.c
Date Wed, 18 Feb 2015 15:45:25 GMT
Author: rhuijben
Date: Wed Feb 18 15:45:24 2015
New Revision: 1660659

URL: http://svn.apache.org/r1660659
Log:
Following up on r1660610 and r1660641, just get rid of the pool handling
inside the sqlite function callbacks. Our current users don't need it and
if needed by somebody else it can be handled via the baton.

* subversion/include/private/svn_sqlite.h
  (svn_sqlite__func_t): Replace scratch_pool argument with baton.

* subversion/libsvn_subr/sqlite.c
  (function_wrapper_baton_t): Remove pools.
  (wrapped_func): Just pass the actual sqlite3 values to the inner
    function.
  (clear_sqlite_function_scratch,
   clear_sqlite_function_state,
   clear_sqlite_function_scratch): Remove.
  (svn_sqlite__create_scalar_function): Remove pool registrations.
  (svn_sqlite__value_type,
   svn_sqlite__value_text): Assume other argument type.

* subversion/libsvn_wc/wc_db_util.c
  (relpath_depth_sqlite): Change argument.

* subversion/tests/libsvn_subr/sqlite-test.c
  (error_second): Change argument.

Modified:
    subversion/trunk/subversion/include/private/svn_sqlite.h
    subversion/trunk/subversion/libsvn_subr/sqlite.c
    subversion/trunk/subversion/libsvn_wc/wc_db_util.c
    subversion/trunk/subversion/tests/libsvn_subr/sqlite-test.c

Modified: subversion/trunk/subversion/include/private/svn_sqlite.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_sqlite.h?rev=1660659&r1=1660658&r2=1660659&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_sqlite.h (original)
+++ subversion/trunk/subversion/include/private/svn_sqlite.h Wed Feb 18 15:45:24 2015
@@ -63,7 +63,7 @@ typedef enum svn_sqlite__mode_e {
 typedef svn_error_t *(*svn_sqlite__func_t)(svn_sqlite__context_t *sctx,
                                            int argc,
                                            svn_sqlite__value_t *values[],
-                                           apr_pool_t *scatch_pool);
+                                           void *baton);
 
 
 /* Step the given statement; if it returns SQLITE_DONE, reset the statement.

Modified: subversion/trunk/subversion/libsvn_subr/sqlite.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/sqlite.c?rev=1660659&r1=1660658&r2=1660659&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/sqlite.c (original)
+++ subversion/trunk/subversion/libsvn_subr/sqlite.c Wed Feb 18 15:45:24 2015
@@ -1477,9 +1477,6 @@ struct function_wrapper_baton_t
 {
   svn_sqlite__func_t func;
   void *baton;
-
-  apr_pool_t *scratch_pool;
-  apr_pool_t *state_pool;
 };
 
 static void
@@ -1489,22 +1486,12 @@ wrapped_func(sqlite3_context *context,
 {
   struct function_wrapper_baton_t *fwb = sqlite3_user_data(context);
   svn_sqlite__context_t sctx;
-  svn_sqlite__value_t **local_vals =
-                            apr_palloc(fwb->scratch_pool,
-                                       sizeof(svn_sqlite__value_t *) * argc);
   svn_error_t *err;
-  int i;
+  void *void_values = values;
 
   sctx.context = context;
 
-  for (i = 0; i < argc; i++)
-    {
-      local_vals[i] = apr_palloc(fwb->scratch_pool, sizeof(*local_vals[i]));
-      local_vals[i]->value = values[i];
-    }
-
-  err = fwb->func(&sctx, argc, local_vals, fwb->scratch_pool);
-  svn_pool_clear(fwb->scratch_pool);
+  err = fwb->func(&sctx, argc, void_values, fwb->baton);
 
   if (err)
     {
@@ -1516,34 +1503,6 @@ wrapped_func(sqlite3_context *context,
     }
 }
 
-/* Forward definition */
-static apr_status_t clear_sqlite_function_scratch(void *baton);
-
-/* pool cleanup function for function context on state pool */
-static apr_status_t
-clear_sqlite_function_state(void *baton)
-{
-  struct function_wrapper_baton_t *fwb = baton;
-
-  svn_pool_destroy(fwb->scratch_pool);
-
-  apr_pool_cleanup_kill(fwb->scratch_pool, baton,
-                        clear_sqlite_function_scratch);
-
-  return APR_SUCCESS;
-}
-
-/* pool cleanup function for global cleanup on internal pool */
-static apr_status_t
-clear_sqlite_function_scratch(void *baton)
-{
-  struct function_wrapper_baton_t *fwb = baton;
-
-  apr_pool_cleanup_kill(fwb->state_pool, baton,
-                        clear_sqlite_function_state);
-
-  return APR_SUCCESS;
-}
 
 svn_error_t *
 svn_sqlite__create_scalar_function(svn_sqlite__db_t *db,
@@ -1564,8 +1523,6 @@ svn_sqlite__create_scalar_function(svn_s
      We create a subpool in the global pool and only destroy it
      when we want it to be destroyed */
 
-  fwb->state_pool = db->state_pool;
-  fwb->scratch_pool = svn_pool_create(NULL);
   fwb->func = func;
   fwb->baton = baton;
 
@@ -1577,26 +1534,21 @@ svn_sqlite__create_scalar_function(svn_s
                                      fwb, wrapped_func, NULL, NULL),
              db);
 
-  apr_pool_cleanup_register(fwb->state_pool, fwb,
-                            clear_sqlite_function_state,
-                            apr_pool_cleanup_null);
-  apr_pool_cleanup_register(fwb->scratch_pool, fwb,
-                            clear_sqlite_function_scratch,
-                            apr_pool_cleanup_null);
-
   return SVN_NO_ERROR;
 }
 
 int
 svn_sqlite__value_type(svn_sqlite__value_t *val)
 {
-  return sqlite3_value_type(val->value);
+  void *v = val;
+  return sqlite3_value_type(v);
 }
 
 const char *
 svn_sqlite__value_text(svn_sqlite__value_t *val)
 {
-  return (const char *) sqlite3_value_text(val->value);
+  void *v = val;
+  return (const char *) sqlite3_value_text(v);
 }
 
 void

Modified: subversion/trunk/subversion/libsvn_wc/wc_db_util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db_util.c?rev=1660659&r1=1660658&r2=1660659&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db_util.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db_util.c Wed Feb 18 15:45:24 2015
@@ -83,7 +83,7 @@ static svn_error_t *
 relpath_depth_sqlite(svn_sqlite__context_t *sctx,
                      int argc,
                      svn_sqlite__value_t *values[],
-                     apr_pool_t *scratch_pool)
+                     void *baton)
 {
   const char *path = NULL;
   apr_int64_t depth;

Modified: subversion/trunk/subversion/tests/libsvn_subr/sqlite-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_subr/sqlite-test.c?rev=1660659&r1=1660658&r2=1660659&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_subr/sqlite-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_subr/sqlite-test.c Wed Feb 18 15:45:24 2015
@@ -49,7 +49,7 @@ static svn_error_t *
 error_second(svn_sqlite__context_t *sctx,
              int argc,
              svn_sqlite__value_t *values[],
-             apr_pool_t *scratch_pool)
+             void *baton)
 {
   static int i = 0;
 



Mime
View raw message