diff options
author | Araq <rumpf_a@web.de> | 2013-01-27 19:15:13 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2013-01-27 19:15:13 +0100 |
commit | 07585088955c1fe8fb815c40409ed9f5d66fd446 (patch) | |
tree | 0179ff01c39469a61cdc2644ba5d9cc3b29181e8 /lib/core | |
parent | 0e1b67cfff7f9e7352439888e06e2c255599e193 (diff) | |
download | Nim-07585088955c1fe8fb815c40409ed9f5d66fd446.tar.gz |
bugfix: typeinfo.extendSeq
Diffstat (limited to 'lib/core')
-rwxr-xr-x | lib/core/typeinfo.nim | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/core/typeinfo.nim b/lib/core/typeinfo.nim index 26a14f444..eb2a0c9e5 100755 --- a/lib/core/typeinfo.nim +++ b/lib/core/typeinfo.nim @@ -1,7 +1,7 @@ # # # Nimrod's Runtime Library -# (c) Copyright 2012 Dominik Picheta, Andreas Rumpf +# (c) Copyright 2013 Dominik Picheta, Andreas Rumpf # # See the file "copying.txt", included in this # distribution, for details about the copyright. @@ -139,12 +139,15 @@ proc invokeNewSeq*(x: TAny, len: int) = var z = newSeq(x.rawType, len) genericShallowAssign(x.value, addr(z), x.rawType) -proc extendSeq*(x: TAny, elems = 1) = - ## performs ``setLen(x, x.len+elems)``. `x` needs to represent a ``seq``. +proc extendSeq*(x: TAny) = + ## performs ``setLen(x, x.len+1)``. `x` needs to represent a ``seq``. assert x.rawType.kind == tySequence var y = cast[ptr PGenSeq](x.value)[] - var z = incrSeq(y, x.rawType.base.size * elems) - genericShallowAssign(x.value, addr(z), x.rawType) + var z = incrSeq(y, x.rawType.base.size) + # 'incrSeq' already freed the memory for us and copied over the RC! + # So we simply copy the raw pointer into 'x.value': + cast[ppointer](x.value)[] = z + #genericShallowAssign(x.value, addr(z), x.rawType) proc setObjectRuntimeType*(x: TAny) = ## this needs to be called to set `x`'s runtime object type field. |