You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Greg Stein <gs...@lyra.org> on 2001/01/24 22:52:54 UTC

Re: CVS update: subversion/subversion/libsvn_fs txn-table.c

It might be easier to use an apr_array_header_t in there, and then just
return (char **)ary->elts.

It would certainly simplify the count/size and alloc/realloc logic.

Cheers,
-g

On Wed, Jan 24, 2001 at 10:13:28PM -0000, jimb@tigris.org wrote:
>   User: jimb    
>   Date: 01/01/24 14:13:28
> 
>   Modified:    subversion/libsvn_fs txn-table.c
>   Log:
>   * libsvn_fs/txn-table.c (svn_fs__get_txn_list): Don't set *NAMES_P
>   until we know the operation has succeeded.
>   
>   Revision  Changes    Path
>   1.9       +14 -9     subversion/subversion/libsvn_fs/txn-table.c
>   
>   Index: txn-table.c
>   ===================================================================
>   RCS file: /cvs/subversion/subversion/libsvn_fs/txn-table.c,v
>   retrieving revision 1.8
>   retrieving revision 1.9
>   diff -u -r1.8 -r1.9
>   --- txn-table.c	2001/01/24 18:56:25	1.8
>   +++ txn-table.c	2001/01/24 22:13:28	1.9
>   @@ -236,14 +236,16 @@
>    {
>      int const next_id_key_len = strlen (next_id_key);
>    
>   +  char **names;
>   +  apr_size_t names_count = 0;
>   +  apr_size_t names_size = 4;
>   +
>      DBC *cursor;
>      DBT key, value;
>   -  db_recno_t names_count = 0;
>   -  db_recno_t names_size = 4;
>      int db_err, db_c_err;
>    
>      /* Allocate the initial names array */
>   -  *names_p = apr_pcalloc (pool, names_size * sizeof (**names_p));
>   +  names = apr_pcalloc (pool, names_size * sizeof (*names));
>    
>      /* Create a database cursor to list the transaction names. */
>      SVN_ERR (DB_WRAP (fs, "reading transaction list (opening cursor)",
>   @@ -271,19 +273,21 @@
>          /* Make sure there's enough space in the names array. */
>          if (names_count == names_size - 1)
>            {
>   -          char **tmp = apr_pcalloc (pool, 2 * names_size * sizeof (*tmp));
>   -          memcpy (tmp, *names_p, names_size * sizeof (*tmp));
>   -          *names_p = tmp;
>   +          char **tmp;
>   +
>              names_size *= 2;
>   +          tmp = apr_pcalloc (pool, names_size * sizeof (*tmp));
>   +          memcpy (tmp, names, names_count * sizeof (*tmp));
>   +          names = tmp;
>            }
>    
>   -      (*names_p)[names_count++] = apr_pstrndup (pool, key.data, key.size);
>   +      names[names_count++] = key.data;
>        }
>    
>   -  (*names_p)[names_count] = NULL;
>   +  names[names_count] = NULL;
>    
>      /* Check for errors, but close the cursor first. */
>   -  db_c_err = cursor->c_close(cursor);
>   +  db_c_err = cursor->c_close (cursor);
>      if (db_err != DB_NOTFOUND)
>        {
>          SVN_ERR (DB_WRAP (fs, "reading transaction list (listing keys)",
>   @@ -292,6 +296,7 @@
>      SVN_ERR (DB_WRAP (fs, "reading transaction list (closing cursor)",
>                        db_c_err));
>    
>   +  *names_p = names;
>      return SVN_NO_ERROR;
>    }
>    
>   
>   
>   

-- 
Greg Stein, http://www.lyra.org/

Re: CVS update: subversion/subversion/libsvn_fs txn-table.c

Posted by Branko Čibej <br...@xbc.nu>.
Greg Stein wrote:

> It might be easier to use an apr_array_header_t in there, and then just
> return (char **)ary->elts.
> 
> It would certainly simplify the count/size and alloc/realloc logic.

Yes!

Jim, I think we could do the same with svn_fs_id_t, and maybe elsewhere. 
If you agree, I'll have a go at it.

-- 
Brane �ibej
    home:   <br...@xbc.nu>             http://www.xbc.nu/brane/
    work:   <br...@hermes.si>   http://www.hermes-softlab.com/
     ACM:   <br...@acm.org>            http://www.acm.org/