Multiple Dynamic Array
Bill Baxter
dnewsgroup at billbaxter.com
Tue Dec 26 09:41:46 PST 2006
Jarrett Billingsley wrote:
> "Bill Baxter" <dnewsgroup at billbaxter.com> wrote in message
> news:empvht$9vk$1 at digitaldaemon.com...
>
>> Jarrett, is that equivalent to doing the nested loop allocations above? Or
>> does it allocate one contiguous chunk and then set the pointers to point
>> inside of that? Just curious, because if you're allocating a huge amount
>> of memory that way, then you don't always want it to be contiguous,
>> because there may not be a single block of memory available that's big
>> enough.
>
> The new int[][][](64, 64, 64) syntax calls _d_newm, which is defined in
> dmd/src/phobos/internal/gc/gc.d. It allocates several smaller blocks -- one
> for each dimension and for each element, and sets up the pointers/lengths
> for you.
Thanks. Yeh, I guess that behavior makes the most sense, since given an
arbitrary int[][][] foo one would expect to be able to do things like
change foo[0].length and actually have memory freed. That would be
difficult if everything were all allocated as one block.
--bb
More information about the Digitalmars-d-learn
mailing list