diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-11-28 01:28:39 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-11-28 01:28:39 -0800 |
commit | 11d10eb09311bcc975605709d476acd2025c242b (patch) | |
tree | 1050428481241ae26c3e5ad7bb8101a58ae6959c | |
parent | 3c67fedb9b54ce954b165730898ab88a19d318be (diff) | |
download | mu-11d10eb09311bcc975605709d476acd2025c242b.tar.gz |
2491
-rw-r--r-- | 010vm.cc | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/010vm.cc b/010vm.cc index ab003c73..53e40b0a 100644 --- a/010vm.cc +++ b/010vm.cc @@ -60,6 +60,7 @@ struct reagent { reagent(string s); reagent(); ~reagent(); + void clear(); reagent(const reagent& old); reagent& operator=(const reagent& old); void set_value(double v) { value = v; initialized = true; } @@ -319,9 +320,18 @@ reagent& reagent::operator=(const reagent& old) { } reagent::~reagent() { - for (long long int i = 0; i < SIZE(properties); ++i) - if (properties.at(i).second) delete properties.at(i).second; + clear(); +} + +void reagent::clear() { + for (long long int i = 0; i < SIZE(properties); ++i) { + if (properties.at(i).second) { + delete properties.at(i).second; + properties.at(i).second = NULL; + } + } delete type; + type = NULL; } type_tree::~type_tree() { delete left; |