about summary refs log tree commit diff stats
path: root/032array.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-05-03 17:38:33 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-05-03 17:38:33 -0700
commit6e793202e3dd9a89b88ab291cebbcb788337c592 (patch)
tree964576ac4bca556076c5fe09c4f0323f6e78f774 /032array.cc
parent191e9bb224cad7c3ea62d986a89a9aa6301c1966 (diff)
downloadmu-6e793202e3dd9a89b88ab291cebbcb788337c592.tar.gz
2898 - start filling in missing refcounts
This commit covers instructions 'put', 'put-index' and 'maybe-convert'.
Next up are the harder ones: 'copy' and 'merge'. In these cases there's
a non-scalar being copied, and we need to figure out which locations
within it need to update their refcount.
Diffstat (limited to '032array.cc')
-rw-r--r--032array.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/032array.cc b/032array.cc
index a40f9e20..3d93e84d 100644
--- a/032array.cc
+++ b/032array.cc
@@ -361,13 +361,15 @@ case PUT_INDEX: {
     raise << maybe(current_recipe_name()) << "invalid index " << no_scientific(index_val.at(0)) << '\n' << end();
     break;
   }
-  type_tree* element_type = copy_array_element(base.type);
-  int address = base_address + 1 + index_val.at(0)*size_of(element_type);
-  delete element_type;
+  reagent element;
+  element.type = copy_array_element(base.type);
+  int address = base_address + 1 + index_val.at(0)*size_of(element.type);
+  element.value = address;
   trace(9998, "run") << "address to copy to is " << address << end();
   // optimization: directly write the element rather than updating 'product'
   // and writing the entire array
   vector<double> value = read_memory(current_instruction().ingredients.at(2));
+  // Write Memory in PUT_INDEX in Run
   for (int i = 0; i < SIZE(value); ++i) {
     trace(9999, "mem") << "storing " << no_scientific(value.at(i)) << " in location " << address+i << end();
     put(Memory, address+i, value.at(i));