Allocate N elements

Namespace rswhite4 at googlemail.com
Mon Jul 15 12:53:32 PDT 2013


On Monday, 15 July 2013 at 18:29:12 UTC, Adam D. Ruppe wrote:
> On Monday, 15 July 2013 at 18:16:45 UTC, Namespace wrote:
>> writeln(arr.length, "::", arr.capacity);
>
> arr.capacity checks the GC block, and since you malloced it, 
> there is no gc block for it to check. So it simply doesn't know 
> if there's any extra capacity there and reports 0 just to be 
> safe.

Ah, good to know. But anyway malloc allocates exact N elements, 
without ugly overhead.
Would be really good if there was a way to avoid that the GC 
takes over the memory.


More information about the Digitalmars-d-learn mailing list