From 829fcd8374ea9029119bb37c42aeecf53523995c Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 21 May 2017 14:25:16 -0700 Subject: 3875 --- 036refcount.cc | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to '036refcount.cc') diff --git a/036refcount.cc b/036refcount.cc index f3d27c82..80000347 100644 --- a/036refcount.cc +++ b/036refcount.cc @@ -69,24 +69,23 @@ void decrement_any_refcounts(const reagent& canonized_x) { void decrement_refcount(int old_address, const type_tree* payload_type, int payload_size) { assert(old_address >= 0); - if (old_address) { - int old_refcount = get_or_insert(Memory, old_address); - trace(9999, "mem") << "decrementing refcount of " << old_address << ": " << old_refcount << " -> " << old_refcount-1 << end(); - --old_refcount; - put(Memory, old_address, old_refcount); - if (old_refcount < 0) { - tb_shutdown(); - cerr << "Negative refcount!!! " << old_address << ' ' << old_refcount << '\n'; - if (Trace_stream) { - cerr << "Saving trace to last_trace.\n"; - ofstream fout("last_trace"); - fout << Trace_stream->readable_contents(""); - fout.close(); - } - exit(0); + if (old_address == 0) return; + int old_refcount = get_or_insert(Memory, old_address); + trace(9999, "mem") << "decrementing refcount of " << old_address << ": " << old_refcount << " -> " << old_refcount-1 << end(); + --old_refcount; + put(Memory, old_address, old_refcount); + if (old_refcount < 0) { + tb_shutdown(); + cerr << "Negative refcount!!! " << old_address << ' ' << old_refcount << '\n'; + if (Trace_stream) { + cerr << "Saving trace to last_trace.\n"; + ofstream fout("last_trace"); + fout << Trace_stream->readable_contents(""); + fout.close(); } - // End Decrement Refcount(old_address, payload_type, payload_size) + exit(0); } + // End Decrement Refcount(old_address, payload_type, payload_size) } int payload_size(reagent/*copy*/ x) { -- cgit 1.4.1-2-gfad0