Replacing C's memcpy with a D implementation

Walter Bright newshound2 at digitalmars.com
Mon Jun 11 16:13:38 UTC 2018


On 6/11/2018 6:00 AM, Steven Schveighoffer wrote:
> No, __doPostblit is necessary -- you are making a copy.
> 
> example:
> 
> File[] fs = new File[5];
> 
> fs[0] = ...; // initialize fs
> auto fs2 = fs;
> fs.length = 100;
> 
> At this point, fs points at a separate block from fs2. If you did not do 
> postblit on this, then when one of those arrays is destroyed, the other will 
> become invalid, as the File reference count would go to 0.

Yes, you're right. This should probably go as a comment in the code in case it 
comes up again.


More information about the Digitalmars-d mailing list