How to call destructor before free without dropping @nogc?
    evilrat 
    evilrat666 at gmail.com
       
    Thu Aug 19 15:38:19 UTC 2021
    
    
  
On Thursday, 19 August 2021 at 15:12:03 UTC, Ferhat Kurtulmuş 
wrote:
> On Thursday, 19 August 2021 at 07:30:38 UTC, Bienlein wrote:
>> Hello,
>>
>> I allocate some instance of class C manually and then free the 
>> memory again:
>>
>> [...]
>
> I just wanted to leave this here.
> https://github.com/AuburnSounds/Dplug/blob/master/core/dplug/core/nogc.d
This is cool, but even in unit tests for malloc wrapper there is 
only simple case with class without references to another class 
and no dtor.
Seems like the issue is that one have to add @nogc 
constructor/destructor overloads for emplace/destroy, and the 
author can't have @nogc dtor because of writeln (IIRC @nogc using 
GC is allowed with `debug` anyway), and all class members of 
another classes must recursively provide them as well.
    
    
More information about the Digitalmars-d-learn
mailing list