diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-05-15 16:24:34 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-05-15 16:24:34 -0700 |
commit | 5f06655c6a76989db28e3484444573a949c28c9f (patch) | |
tree | fb1fcbbcf3e3e599d601ee1c2269989843524425 | |
parent | 7c9570f0cdcdbe49744364f309bd9e50ae98fb9f (diff) | |
download | mu-5f06655c6a76989db28e3484444573a949c28c9f.tar.gz |
1379 - avoid all uninitialized-memory issues
-rw-r--r-- | 042new.cc | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/042new.cc b/042new.cc index a4e00490..68ae1949 100644 --- a/042new.cc +++ b/042new.cc @@ -76,7 +76,10 @@ case NEW: { // save result products.resize(1); products.at(0).push_back(result); - // initialize array if necessary + // initialize allocated space + for (index_t address = result; address < result+size; ++address) { + Memory[address] = 0; + } if (current_instruction().ingredients.size() > 1) { Memory[result] = array_length; } @@ -100,6 +103,15 @@ void ensure_space(size_t size) { } } +:(scenario new_initializes) +% Memory_allocated_until = 10; +% Memory[Memory_allocated_until] = 1; +recipe main [ + 1:address:number <- new number:type + 2:number <- copy 1:address:number/deref +] ++mem: storing 0 in location 2 + :(scenario new_array) recipe main [ 1:address:array:number/raw <- new number:type, 5:literal |