Deallocate array?

Ali Çehreli acehreli at yahoo.com
Thu May 9 20:25:39 PDT 2013


On 05/09/2013 07:43 PM, Steven Schveighoffer wrote:

 > On Thu, 09 May 2013 22:14:41 -0400, Ali Çehreli <acehreli at yahoo.com> 
wrote:

 >> Then, each of those strings point at 22 bytes of individully allocated
 >> memory areas.
 >
 > No, each array points at static data.  Strings are immutables stored in
 > the data segment.

You are right. They start at pointing to the same string but as soon as 
each string is used in a special way, say each gets appended a char, 
then they own their special characters:

             s = "aaaaaaaaaaaaaaaaaaaaa";

             // Some time later:
             s ~= 'x';

Now each s.ptr is different.

Ali



More information about the Digitalmars-d-learn mailing list