about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-02-19 02:43:36 -0800
committerKartik K. Agaram <vc@akkartik.com>2016-02-19 02:43:36 -0800
commitf6c7b4155936e7c5485a14abcbb458d0c3bbd882 (patch)
treecdb73c56c6398f40076f55559ba4908320f742a9
parentd4dea9bd5f2f80795bd1bf6871c73b863f0525a1 (diff)
downloadmu-f6c7b4155936e7c5485a14abcbb458d0c3bbd882.tar.gz
2680
Memory leaks fixed.
-rw-r--r--058shape_shifting_container.cc52
-rw-r--r--077hash.cc2
2 files changed, 27 insertions, 27 deletions
diff --git a/058shape_shifting_container.cc b/058shape_shifting_container.cc
index 319f0381..05466e3d 100644
--- a/058shape_shifting_container.cc
+++ b/058shape_shifting_container.cc
@@ -396,17 +396,17 @@ void test_replace_last_type_ingredient_with_multiple() {
       "  y:_b\n"
       "]\n");
   reagent callsite("{f: (foo number (address shared array character))}");
-  reagent element = element_type(callsite, 0);
-  CHECK_EQ(element.name, "x");
-  CHECK_EQ(element.properties.at(0).second->value, "number");
-  CHECK(!element.properties.at(0).second->right);
-  element = element_type(callsite, 1);
-  CHECK_EQ(element.name, "y");
-  CHECK_EQ(element.properties.at(0).second->value, "address");
-  CHECK_EQ(element.properties.at(0).second->right->value, "shared");
-  CHECK_EQ(element.properties.at(0).second->right->right->value, "array");
-  CHECK_EQ(element.properties.at(0).second->right->right->right->value, "character");
-  CHECK(!element.properties.at(0).second->right->right->right->right);
+  reagent element1 = element_type(callsite, 0);
+  CHECK_EQ(element1.name, "x");
+  CHECK_EQ(element1.properties.at(0).second->value, "number");
+  CHECK(!element1.properties.at(0).second->right);
+  reagent element2 = element_type(callsite, 1);
+  CHECK_EQ(element2.name, "y");
+  CHECK_EQ(element2.properties.at(0).second->value, "address");
+  CHECK_EQ(element2.properties.at(0).second->right->value, "shared");
+  CHECK_EQ(element2.properties.at(0).second->right->right->value, "array");
+  CHECK_EQ(element2.properties.at(0).second->right->right->right->value, "character");
+  CHECK(!element2.properties.at(0).second->right->right->right->right);
 }
 
 void test_replace_middle_type_ingredient_with_multiple() {
@@ -416,21 +416,21 @@ void test_replace_middle_type_ingredient_with_multiple() {
       "  z:_c\n"
       "]\n");
   reagent callsite("{f: (foo number (address shared array character) boolean)}");
-  reagent element = element_type(callsite, 0);
-  CHECK_EQ(element.name, "x");
-  CHECK_EQ(element.properties.at(0).second->value, "number");
-  CHECK(!element.properties.at(0).second->right);
-  element = element_type(callsite, 1);
-  CHECK_EQ(element.name, "y");
-  CHECK_EQ(element.properties.at(0).second->value, "address");
-  CHECK_EQ(element.properties.at(0).second->right->value, "shared");
-  CHECK_EQ(element.properties.at(0).second->right->right->value, "array");
-  CHECK_EQ(element.properties.at(0).second->right->right->right->value, "character");
-  CHECK(!element.properties.at(0).second->right->right->right->right);
-  element = element_type(callsite, 2);
-  CHECK_EQ(element.name, "z");
-  CHECK_EQ(element.properties.at(0).second->value, "boolean");
-  CHECK(!element.properties.at(0).second->right);
+  reagent element1 = element_type(callsite, 0);
+  CHECK_EQ(element1.name, "x");
+  CHECK_EQ(element1.properties.at(0).second->value, "number");
+  CHECK(!element1.properties.at(0).second->right);
+  reagent element2 = element_type(callsite, 1);
+  CHECK_EQ(element2.name, "y");
+  CHECK_EQ(element2.properties.at(0).second->value, "address");
+  CHECK_EQ(element2.properties.at(0).second->right->value, "shared");
+  CHECK_EQ(element2.properties.at(0).second->right->right->value, "array");
+  CHECK_EQ(element2.properties.at(0).second->right->right->right->value, "character");
+  CHECK(!element2.properties.at(0).second->right->right->right->right);
+  reagent element3 = element_type(callsite, 2);
+  CHECK_EQ(element3.name, "z");
+  CHECK_EQ(element3.properties.at(0).second->value, "boolean");
+  CHECK(!element3.properties.at(0).second->right);
 }
 
 bool has_nth_type(const type_tree* base, long long int n) {
diff --git a/077hash.cc b/077hash.cc
index d5e45095..a42b439a 100644
--- a/077hash.cc
+++ b/077hash.cc
@@ -77,7 +77,7 @@ size_t hash_mu_string(size_t h, const reagent& r) {
 size_t hash_mu_array(size_t h, const reagent& r) {
   long long int size = get_or_insert(Memory, r.value);
   reagent elem = r;
-  drop_from_type(elem, "array");
+  delete elem.type;
   elem.type = new type_tree(*array_element(r.type));
   for (long long int i=0, address = r.value+1; i < size; ++i, address += size_of(elem)) {
     reagent tmp = elem;