A few questions regarding GC.malloc

monarch_dodra via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Sep 26 12:24:42 PDT 2014


On Friday, 26 September 2014 at 18:03:40 UTC, Steven 
Schveighoffer wrote:
> On 9/25/14 6:03 PM, Sean Kelly wrote:
>> On Thursday, 25 September 2014 at 21:43:53 UTC, monarch_dodra 
>> wrote:
>>> On Thursday, 25 September 2014 at 20:58:29 UTC, Gary 
>>> Willoughby wrote:
>>>> What does BlkAttr.FINALIZE do when used in the GC.malloc 
>>>> call?
>>>
>>> I have no idea. I think its for classes though, since we 
>>> (currently)
>>> don't finalize structs anyways.
>>
>> Yes it's for memory blocks containing class instances.  It 
>> basically
>> tells the GC to call Object.~this() when collecting the block.
>
> Just to add to Sean's statement, don't use this flag. It will 
> crash the runtime, unless you have properly set up the 
> classinfo pointer :) It does NOT work on structs, though I 
> think there is a PR in the works to have structs destroyed from 
> the GC.
>
> -Steve

Kind of like APPENDABLE I guess, since it only works if you 
correctly setup the appendable data, and correctly slice at the 
correct offset, both of which are implementation defined.


More information about the Digitalmars-d-learn mailing list