# # # patch "rcs_import.cc" # from [7fc100afc70855c8aeccd2c7af406c5c96930b80] # to [89624a5e4f66b5009709aafa98a050815d00fe0e] # ============================================================ --- rcs_import.cc 7fc100afc70855c8aeccd2c7af406c5c96930b80 +++ rcs_import.cc 89624a5e4f66b5009709aafa98a050815d00fe0e @@ -453,6 +453,36 @@ typedef struct blob_index_iter ei; } dfs_context; +// okay, this is a little memory hackery... +#define POOL_SIZE (1024 * 1024 * 4) +struct event_pool +{ + char *pool_start, *pool_end; + + event_pool(void) + : pool_start(NULL), + pool_end(NULL) + { }; + + template + T *allocate(void) + { + u32 s = sizeof(T); + + if ((pool_end - pool_start) <= s) + { + pool_start = (char*) malloc(POOL_SIZE); + pool_end = pool_start + POOL_SIZE; + } + + I((pool_end - pool_start) > s); + T* res = (T*) pool_start; + memset(res, 0, sizeof(T)); + pool_start += s; + return res; + } +}; + struct blob_splitter; string get_event_repr(cvs_history & cvs, cvs_event_ptr ev); @@ -460,6 +490,8 @@ cvs_history struct cvs_history { + event_pool ev_pool; + interner authorclog_interner; interner mtn_version_interner; interner rcs_version_interner; @@ -1343,9 +1375,9 @@ process_rcs_branch(cvs_symbol_no const & cvs_rcs_version rv = cvs.rcs_version_interner.intern(curr_version); curr_commit = - new cvs_commit(cvs.curr_file_interned, - commit_time, mv, rv, - ac, alive); + new (cvs.ev_pool.allocate()) + cvs_commit(cvs.curr_file_interned, commit_time, + mv, rv, ac, alive); if (!first_commit) first_commit = curr_commit; @@ -1372,8 +1404,9 @@ process_rcs_branch(cvs_symbol_no const & cvs_symbol_no tag = cvs.symbol_interner.intern(i->second); cvs_event_ptr tag_symbol = (cvs_event_ptr) - new cvs_symbol(curr_commit->path, tag, - curr_commit->given_time); + new (cvs.ev_pool.allocate()) + cvs_symbol(curr_commit->path, tag, + curr_commit->given_time); tag_symbol->adj_time = curr_commit->adj_time + 1; if (alive) @@ -1395,8 +1428,9 @@ process_rcs_branch(cvs_symbol_no const & add_weak_dependencies(tag_symbol, last_events, reverse_import); cvs_event_ptr tag_event = (cvs_event_ptr) - new cvs_tag_point(curr_commit->path, tag, - curr_commit->given_time); + new (cvs.ev_pool.allocate()) + cvs_tag_point(curr_commit->path, tag, + curr_commit->given_time); tag_event->adj_time = curr_commit->adj_time + 2; add_dependency(tag_event, tag_symbol); @@ -1460,8 +1494,9 @@ process_rcs_branch(cvs_symbol_no const & L(FL("finished private RCS branch %s") % (*i)); cvs_event_ptr branch_point = (cvs_event_ptr) - new cvs_symbol(curr_commit->path, bname, - curr_commit->given_time); + new (cvs.ev_pool.allocate()) + cvs_symbol(curr_commit->path, bname, + curr_commit->given_time); branch_point->adj_time = curr_commit->adj_time + 1; // Normal branches depend on the current commit. But vendor @@ -1490,8 +1525,9 @@ process_rcs_branch(cvs_symbol_no const & // distinction may be confusing, it really helps later on // when determining what branch a blob belongs to. cvs_event_ptr branch_start = (cvs_event_ptr) - new cvs_branch_start(curr_commit->path, bname, - curr_commit->given_time); + new (cvs.ev_pool.allocate()) + cvs_branch_start(curr_commit->path, bname, + curr_commit->given_time); branch_start->adj_time = curr_commit->adj_time + 2; cvs.append_event(branch_start); add_dependency(first_event_in_branch, branch_start); @@ -1556,9 +1592,10 @@ process_rcs_branch(cvs_symbol_no const & if (curr_commit) { cvs_event_ptr branch_end_point = - new cvs_branch_end(cvs.curr_file_interned, - current_branchname, - first_commit->given_time + 1); + new (cvs.ev_pool.allocate()) + cvs_branch_end(cvs.curr_file_interned, + current_branchname, + first_commit->given_time + 1); cvs.append_event(branch_end_point); add_dependency(branch_end_point, first_commit); @@ -1571,9 +1608,10 @@ process_rcs_branch(cvs_symbol_no const & if (first_commit) { cvs_event_ptr branch_end_point = - new cvs_branch_end(cvs.curr_file_interned, - current_branchname, - curr_commit->given_time + 1); + new (cvs.ev_pool.allocate()) + cvs_branch_end(cvs.curr_file_interned, + current_branchname, + curr_commit->given_time + 1); cvs.append_event(branch_end_point); add_dependency(branch_end_point, curr_commit);