Use unique_ptr instead of std::auto_ptr
This commit is contained in:
parent
477a9106e3
commit
b6adc8f460
9 changed files with 17 additions and 17 deletions
|
|
@ -1027,12 +1027,12 @@ bool amount_t::parse(std::istream& in, const parse_flags_t& flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate memory for the amount's quantity value. We have to
|
// Allocate memory for the amount's quantity value. We have to
|
||||||
// monitor the allocation in an auto_ptr because this function gets
|
// monitor the allocation in a unique_ptr because this function gets
|
||||||
// called sometimes from amount_t's constructor; and if there is an
|
// called sometimes from amount_t's constructor; and if there is an
|
||||||
// exeception thrown by any of the function calls after this point,
|
// exeception thrown by any of the function calls after this point,
|
||||||
// the destructor will never be called and the memory never freed.
|
// the destructor will never be called and the memory never freed.
|
||||||
|
|
||||||
std::auto_ptr<bigint_t> new_quantity;
|
unique_ptr<bigint_t> new_quantity;
|
||||||
|
|
||||||
if (quantity) {
|
if (quantity) {
|
||||||
if (quantity->refc > 1)
|
if (quantity->refc > 1)
|
||||||
|
|
|
||||||
|
|
@ -139,8 +139,8 @@ xact_t * csv_reader::read_xact(bool rich_data)
|
||||||
|
|
||||||
std::istringstream instr(line);
|
std::istringstream instr(line);
|
||||||
|
|
||||||
std::auto_ptr<xact_t> xact(new xact_t);
|
unique_ptr<xact_t> xact(new xact_t);
|
||||||
std::auto_ptr<post_t> post(new post_t);
|
unique_ptr<post_t> post(new post_t);
|
||||||
|
|
||||||
xact->set_state(item_t::CLEARED);
|
xact->set_state(item_t::CLEARED);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -233,7 +233,7 @@ xact_t * draft_t::insert(journal_t& journal)
|
||||||
throw std::runtime_error(_("'xact' command requires at least a payee"));
|
throw std::runtime_error(_("'xact' command requires at least a payee"));
|
||||||
|
|
||||||
xact_t * matching = NULL;
|
xact_t * matching = NULL;
|
||||||
std::auto_ptr<xact_t> added(new xact_t);
|
unique_ptr<xact_t> added(new xact_t);
|
||||||
|
|
||||||
if (xact_t * xact =
|
if (xact_t * xact =
|
||||||
lookup_probable_account(tmpl->payee_mask.str(), journal.xacts.rbegin(),
|
lookup_probable_account(tmpl->payee_mask.str(), journal.xacts.rbegin(),
|
||||||
|
|
@ -316,7 +316,7 @@ xact_t * draft_t::insert(journal_t& journal)
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (xact_template_t::post_template_t& post, tmpl->posts) {
|
foreach (xact_template_t::post_template_t& post, tmpl->posts) {
|
||||||
std::auto_ptr<post_t> new_post;
|
unique_ptr<post_t> new_post;
|
||||||
|
|
||||||
commodity_t * found_commodity = NULL;
|
commodity_t * found_commodity = NULL;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ namespace {
|
||||||
format_t::element_t * format_t::parse_elements(const string& fmt,
|
format_t::element_t * format_t::parse_elements(const string& fmt,
|
||||||
const optional<format_t&>& tmpl)
|
const optional<format_t&>& tmpl)
|
||||||
{
|
{
|
||||||
std::auto_ptr<element_t> result;
|
unique_ptr<element_t> result;
|
||||||
|
|
||||||
element_t * current = NULL;
|
element_t * current = NULL;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ int main(int argc, char * argv[], char * envp[])
|
||||||
::textdomain("ledger");
|
::textdomain("ledger");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::auto_ptr<global_scope_t> global_scope;
|
unique_ptr<global_scope_t> global_scope;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Create the session object, which maintains nearly all state relating to
|
// Create the session object, which maintains nearly all state relating to
|
||||||
|
|
|
||||||
|
|
@ -309,7 +309,7 @@ void report_t::posts_report(post_handler_ptr handler)
|
||||||
{
|
{
|
||||||
handler = chain_post_handlers(handler, *this);
|
handler = chain_post_handlers(handler, *this);
|
||||||
if (HANDLED(group_by_)) {
|
if (HANDLED(group_by_)) {
|
||||||
std::auto_ptr<post_splitter>
|
unique_ptr<post_splitter>
|
||||||
splitter(new post_splitter(handler, *this, HANDLER(group_by_).expr));
|
splitter(new post_splitter(handler, *this, HANDLER(group_by_).expr));
|
||||||
splitter->set_postflush_func(posts_flusher(handler, *this));
|
splitter->set_postflush_func(posts_flusher(handler, *this));
|
||||||
handler = post_handler_ptr(splitter.release());
|
handler = post_handler_ptr(splitter.release());
|
||||||
|
|
|
||||||
|
|
@ -59,8 +59,8 @@ class session_t : public symbol_scope_t
|
||||||
public:
|
public:
|
||||||
bool flush_on_next_data_file;
|
bool flush_on_next_data_file;
|
||||||
|
|
||||||
std::auto_ptr<journal_t> journal;
|
unique_ptr<journal_t> journal;
|
||||||
parse_context_stack_t parsing_context;
|
parse_context_stack_t parsing_context;
|
||||||
|
|
||||||
explicit session_t();
|
explicit session_t();
|
||||||
virtual ~session_t() {
|
virtual ~session_t() {
|
||||||
|
|
|
||||||
|
|
@ -527,7 +527,7 @@ void instance_t::automated_xact_directive(char * line)
|
||||||
query.parse_args(string_value(skip_ws(line + 1)).to_sequence(),
|
query.parse_args(string_value(skip_ws(line + 1)).to_sequence(),
|
||||||
keeper, false, true);
|
keeper, false, true);
|
||||||
|
|
||||||
std::auto_ptr<auto_xact_t> ae(new auto_xact_t(predicate_t(expr, keeper)));
|
unique_ptr<auto_xact_t> ae(new auto_xact_t(predicate_t(expr, keeper)));
|
||||||
ae->pos = position_t();
|
ae->pos = position_t();
|
||||||
ae->pos->pathname = context.pathname;
|
ae->pos->pathname = context.pathname;
|
||||||
ae->pos->beg_pos = context.line_beg_pos;
|
ae->pos->beg_pos = context.line_beg_pos;
|
||||||
|
|
@ -621,7 +621,7 @@ void instance_t::period_xact_directive(char * line)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
std::auto_ptr<period_xact_t> pe(new period_xact_t(skip_ws(line + 1)));
|
unique_ptr<period_xact_t> pe(new period_xact_t(skip_ws(line + 1)));
|
||||||
pe->pos = position_t();
|
pe->pos = position_t();
|
||||||
pe->pos->pathname = context.pathname;
|
pe->pos->pathname = context.pathname;
|
||||||
pe->pos->beg_pos = context.line_beg_pos;
|
pe->pos->beg_pos = context.line_beg_pos;
|
||||||
|
|
@ -665,7 +665,7 @@ void instance_t::xact_directive(char * line, std::streamsize len)
|
||||||
TRACE_START(xacts, 1, "Time spent handling transactions:");
|
TRACE_START(xacts, 1, "Time spent handling transactions:");
|
||||||
|
|
||||||
if (xact_t * xact = parse_xact(line, len, top_account())) {
|
if (xact_t * xact = parse_xact(line, len, top_account())) {
|
||||||
std::auto_ptr<xact_t> manager(xact);
|
unique_ptr<xact_t> manager(xact);
|
||||||
|
|
||||||
if (context.journal->add_xact(xact)) {
|
if (context.journal->add_xact(xact)) {
|
||||||
manager.release(); // it's owned by the journal now
|
manager.release(); // it's owned by the journal now
|
||||||
|
|
@ -874,7 +874,7 @@ void instance_t::account_directive(char * line)
|
||||||
char * p = skip_ws(line);
|
char * p = skip_ws(line);
|
||||||
account_t * account =
|
account_t * account =
|
||||||
context.journal->register_account(p, NULL, top_account());
|
context.journal->register_account(p, NULL, top_account());
|
||||||
std::auto_ptr<auto_xact_t> ae;
|
unique_ptr<auto_xact_t> ae;
|
||||||
|
|
||||||
while (peek_whitespace_line()) {
|
while (peek_whitespace_line()) {
|
||||||
read_line(line);
|
read_line(line);
|
||||||
|
|
@ -1287,7 +1287,7 @@ post_t * instance_t::parse_post(char * line,
|
||||||
{
|
{
|
||||||
TRACE_START(post_details, 1, "Time spent parsing postings:");
|
TRACE_START(post_details, 1, "Time spent parsing postings:");
|
||||||
|
|
||||||
std::auto_ptr<post_t> post(new post_t);
|
unique_ptr<post_t> post(new post_t);
|
||||||
|
|
||||||
post->xact = xact; // this could be NULL
|
post->xact = xact; // this could be NULL
|
||||||
post->pos = position_t();
|
post->pos = position_t();
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ namespace {
|
||||||
if (! out_event.note.empty() && event.note.empty())
|
if (! out_event.note.empty() && event.note.empty())
|
||||||
event.note = out_event.note;
|
event.note = out_event.note;
|
||||||
|
|
||||||
std::auto_ptr<xact_t> curr(new xact_t);
|
unique_ptr<xact_t> curr(new xact_t);
|
||||||
curr->_date = event.checkin.date();
|
curr->_date = event.checkin.date();
|
||||||
curr->code = out_event.desc; // if it wasn't used above
|
curr->code = out_event.desc; // if it wasn't used above
|
||||||
curr->payee = event.desc;
|
curr->payee = event.desc;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue