TList

Jesse Phillips jessekphillips at gmail.com
Tue Mar 18 18:54:11 PDT 2008


On Wed, 19 Mar 2008 00:15:43 +0100, Frits van Bommel wrote:

> Sclytrack wrote:
>> I was told that adding an array in D uses realloc (Haven't verified
>> this),
> 
> It doesn't use C realloc(). In fact, it can't for several reasons: 1)
> realloc only works on memory allocated by the normal C allocation
> functions (malloc, calloc), which D doesn't use because they don't[*]
> support GC.
> 2) realloc is supposed[*] to free the original if reallocation succeeds
> but the array was moved, which isn't what's supposed to happen when a D
> array grows (the old one is left for anyone who still has references to
> it; the GC cleans it up if that's not the case).

This is something I've wondered about, so D will grow the array in-place 
on the ram?



More information about the Digitalmars-d-learn mailing list