Allocate N elements

Namespace rswhite4 at googlemail.com
Mon Jul 15 11:16:43 PDT 2013


> No. *EVEN* with an "ugly malloc", you'll still over allocate 
> (see above).

----
int* ptr = cast(int*) malloc(513 * int.sizeof);
int[] arr = ptr[0 .. 513];

writeln(arr.length, "::", arr.capacity);
----

Output:
513::0

Where is the over allocation?


More information about the Digitalmars-d-learn mailing list