diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-03-12 20:08:24 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-03-12 20:08:24 -0800 |
commit | 194c4ed71d9f0843cddb61ee7235d8cba05e8855 (patch) | |
tree | 33d0f75480bbeb407ff7154f3122fb6f8b821709 /037new.cc | |
parent | 6700f9f2044b51e76868764f451ede7b1cb24b2d (diff) | |
download | mu-194c4ed71d9f0843cddb61ee7235d8cba05e8855.tar.gz |
2766 - bugfix in reclaiming arrays
Diffstat (limited to '037new.cc')
-rw-r--r-- | 037new.cc | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/037new.cc b/037new.cc index f6b5c744..671a6aca 100644 --- a/037new.cc +++ b/037new.cc @@ -450,7 +450,7 @@ if (x.type->value == get(Type_ordinal, "address") // lookup_memory without drop_one_lookup { trace(9999, "mem") << "automatically abandoning " << old_address << end(); trace(9999, "mem") << "computing size to abandon at " << x.value << end(); - x.set_value(get_or_insert(Memory, x.value)+/*skip refcount*/1); + x.set_value(old_address+/*skip refcount*/1); drop_from_type(x, "address"); drop_from_type(x, "shared"); // } @@ -522,6 +522,19 @@ def foo [ +run: 1:address:shared:number <- new number:type +mem: decrementing refcount of 1000: 2 -> 1 +:(scenario refcounts_array) +def main [ + 1:number <- copy 30 + # allocate an array + 10:address:shared:array:number <- new number:type, 20 + 11:number <- copy 10:address:shared:array:number + # allocate another array in its place, implicitly freeing the previous allocation + 10:address:shared:array:number <- new number:type, 25 +] ++run: 10:address:shared:array:number <- new number:type, 20 +# abandoned array is of old size (20, not 25) ++abandon: saving in free-list of size 22 + //:: Extend 'new' to handle a unicode string literal argument. :(scenario new_string) |