Dynamic array as stack and GC.BlkAttr.APPENDABLE
Rainer Schuetze via Digitalmars-d
digitalmars-d at puremagic.com
Sun Nov 16 01:28:25 PST 2014
On 15.11.2014 23:40, IgorStepanov wrote:
> Do I any fundamental error in this code?
> May be Bucket[] ret = new Bucket[len]; ret.ptr is not base pointer?
Yes, for arrays larger than 2kB, the allocation length information is
placed before the actual data, and ret.ptr has an offset of 16 bytes
into the allocation block. As a consequence, applying
BlkAttr.NO_INTERIOR will very likely cause the block to be collected.
NO_INTERIOR has no effect for smaller blocks.
That's why the existing AA code explicitely uses GC.malloc instead of new[].
More information about the Digitalmars-d
mailing list