Changeset 142


Ignore:
Timestamp:
Aug 8, 2006, 9:23:11 PM (13 years ago)
Author:
Jari Häkkinen
Message:

Fixes #56. Changed pool usage to use subpools that are cleared after usages.

Location:
trunk/lib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Node.h

    r138 r142  
    6363    /// @brief Get the author of the latest commit.
    6464    ///
    65     std::string author(void) const { return svninfo_.last_changed_author(); }
     65    inline const std::string& author(void) const
     66    { return svninfo_.last_changed_author(); }
    6667
    6768    ///
     
    8384    /// @brief Get the revision number of the latest commit.
    8485    ///
    85     svn_revnum_t last_changed_rev(void) const
     86    inline svn_revnum_t last_changed_rev(void) const
    8687    { return svninfo_.last_changed_rev(); }
    8788
  • trunk/lib/SVN.cc

    r140 r142  
    2828#include <apr_allocator.h>
    2929#include <apr_hash.h>
     30#include <svn_client.h>
    3031#include <svn_cmdline.h>
    3132#include <svn_path.h>
     
    4344    : adm_access_(NULL), allocator_(NULL), context_(NULL), pool_(NULL)
    4445  {
    45     // To be honest, I (Jari) am not perfectly sure of what I am
    46     // doing, most bits here are stolen from subversion source for the
    47     // svn command line binary (subverion/svn/main.c)
    48 
    4946    svn_error_t* err=NULL;
    5047
     
    126123    start.value.number=0;
    127124    head.kind=svn_opt_revision_head;
     125    apr_pool_t *subpool = svn_pool_create(pool_);
    128126    svn_error_t* err=svn_client_blame3(path.c_str(), &peg, &start, &head,
    129                                        // Jari, below line creates memory leaks
    130                                        svn_diff_file_options_create(pool_),
    131                                        false, receiver, baton, context_, pool_);
     127                                       svn_diff_file_options_create(subpool),
     128                                       false, receiver, baton, context_,
     129                                       subpool);
    132130    if (err && err->apr_err!=SVN_ERR_CLIENT_IS_BINARY_FILE) {
    133131      svn_handle_error2(err, stderr, false, "svnstat: ");
    134132      svn_error_clear(err);
     133      svn_pool_destroy(subpool);
    135134      throw SVNException("SVN::client_blame: svn_client_blame3 failed");
    136135    }
     136    svn_pool_destroy(subpool);
    137137    return err;
    138138  }
     
    142142                        void *baton)
    143143  {
     144    apr_pool_t *subpool = svn_pool_create(pool_);
    144145    if (svn_error_t *err=svn_client_info(path.c_str(), NULL, NULL, receiver,
    145                                          baton, false, context_, pool_)) {
    146       svn_handle_error2(err, stderr, false, "svnstat: ");
    147       svn_error_clear(err);
     146                                         baton, false, context_, subpool)) {
     147      svn_handle_error2(err, stderr, false, "svnstat: ");
     148      svn_error_clear(err);
     149      svn_pool_destroy(subpool);
    148150      throw SVNException("repository: svn_client_info failed");
    149151    }
     152    svn_pool_destroy(subpool);
    150153  }
    151154
     
    153156  std::vector<std::string> SVN::commit_dates(const std::string& path)
    154157  {
    155     // Allocate space in pool_ for apr_path (here a string).
    156     apr_array_header_t* apr_path=apr_array_make(pool_,1,4);
     158    // Allocate space in subpool to pool_ for apr_path (here a string).
     159    apr_pool_t *subpool = svn_pool_create(pool_);
     160    apr_array_header_t* apr_path=apr_array_make(subpool,1,4);
    157161    // Copy path to apr_path.
    158162    (*((const char **) apr_array_push(apr_path))) =
    159       apr_pstrdup(pool_, svn_path_internal_style(path.c_str(),pool_));
     163      apr_pstrdup(subpool, svn_path_internal_style(path.c_str(),subpool));
    160164
    161165    // Setup to retrieve all commit logs.
     
    168172    // Retrieving the last revision is only needed for the reserve
    169173    // call below, not needed for the functionality here.
    170     if ((err=svn_ra_get_latest_revnum(ra_session_,&(head.value.number),pool_))) {
    171       svn_handle_error2(err, stderr, false, "svnstat: ");
    172       svn_error_clear(err);
     174    if ((err=svn_ra_get_latest_revnum(ra_session_, &(head.value.number),
     175                                      subpool))) {
     176      svn_handle_error2(err, stderr, false, "svnstat: ");
     177      svn_error_clear(err);
     178      svn_pool_destroy(subpool);
    173179      throw SVNException("commit_dates: svn_ra_get_latest_revnum failed");
    174180    }
     
    180186    if ((err=svn_client_log3(apr_path, &peg, &start, &head, 0, false, true,
    181187                             log_message_receiver, static_cast<void*>(&lb),
    182                              context_, pool_))) {
    183       svn_handle_error2(err, stderr, false, "svnstat: ");
    184       svn_error_clear(err);
     188                             context_, subpool))) {
     189      svn_handle_error2(err, stderr, false, "svnstat: ");
     190      svn_error_clear(err);
     191      svn_pool_destroy(subpool);
    185192      throw SVNException("commit_dates: svn_client_log3 failed");
    186193    }
     194    svn_pool_destroy(subpool);
    187195    return lb.commit_dates;
    188196  }
     
    241249  {
    242250    svn_wc_status2_t* status=NULL;
     251    apr_pool_t *subpool = svn_pool_create(pool_);
    243252    if (svn_error_t *err=
    244         svn_wc_status2(&status,svn_path_internal_style(path.c_str(), pool_),
    245                        adm_access_, pool_)) {
     253        svn_wc_status2(&status,svn_path_internal_style(path.c_str(), subpool),
     254                       adm_access_, subpool)) {
    246255      svn_handle_error2(err,stderr,false,"svnstat:");
    247256      svn_error_clear(err);
     257      svn_pool_destroy(subpool);
    248258      throw SVNException("version_controlled(): svn_config_get_config failed");
    249259    }
     260    svn_pool_destroy(subpool);
    250261
    251262    if ((status->text_status==svn_wc_status_none) ||
  • trunk/lib/SVNinfo.cc

    r140 r142  
    4141  svn_error_t *
    4242  SVNinfo::info_receiver(void *baton, const char *, const svn_info_t *info,
    43                          apr_pool_t *pool)
     43                         apr_pool_t*)
    4444  {
    4545    if (!info)
    4646      throw SVNException(std::string("SVNinfo::info_receriver: ") +
    4747                         "Failed to acquire an svn info object");
    48     static_cast<struct info_receiver_baton*>(baton)->info=svn_info_dup(info,
    49                                                                        pool);
     48
     49    info_receiver_baton* irb=static_cast<struct info_receiver_baton*>(baton);
     50    if (info->repos_root_URL)
     51      irb->repos_root_url_=info->repos_root_URL;
     52    if (info->last_changed_author)
     53      irb->last_changed_author_=info->last_changed_author;
     54    if (info->last_changed_rev)
     55      irb->last_changed_rev_=info->last_changed_rev;
     56    if (info->rev)
     57      irb->rev_=info->rev;
     58
    5059    return SVN_NO_ERROR;
    5160  }
  • trunk/lib/SVNinfo.h

    r140 r142  
    5252    /// @brief Get the repository root URL.
    5353    ///
    54     std::string const
    55     repos_root_url(void) { return info_receiver_baton_.info->repos_root_URL; }
     54    inline const std::string& repos_root_url(void) const
     55    { return info_receiver_baton_.repos_root_url_; }
    5656
    5757    ///
    5858    /// @brief Get the author of the latest commit.
    5959    ///
    60     std::string last_changed_author(void) const
    61     { return info_receiver_baton_.info->last_changed_author; }
     60    inline const std::string& last_changed_author(void) const
     61    { return info_receiver_baton_.last_changed_author_; }
    6262
    6363    ///
    6464    /// @brief Get the revision of the latest commit.
    6565    ///
    66     svn_revnum_t last_changed_rev(void) const
    67     { return info_receiver_baton_.info->last_changed_rev; }
     66    inline svn_revnum_t last_changed_rev(void) const
     67    { return info_receiver_baton_.last_changed_rev_; }
    6868
    6969    ///
    7070    /// @brief Get the current revision of the item.
    7171    ///
    72     svn_revnum_t rev(void) const
    73     { return info_receiver_baton_.info->rev; }
     72    inline svn_revnum_t rev(void) const { return info_receiver_baton_.rev_; }
    7473
    7574
     
    9190    ///
    9291    struct info_receiver_baton {
    93       svn_info_t *info;
     92      // more info is available but we only use these
     93      std::string repos_root_url_;
     94      std::string last_changed_author_;
     95      svn_revnum_t last_changed_rev_;
     96      svn_revnum_t rev_;
    9497    } info_receiver_baton_ ;
    9598
Note: See TracChangeset for help on using the changeset viewer.