Destroying structs (literally)

Orvid King via Digitalmars-d digitalmars-d at puremagic.com
Fri Aug 29 11:12:18 PDT 2014


On 8/29/2014 12:41 AM, monarch_dodra wrote:
> Questions:
> - Can and will this work for arrays of structs?
> - When doing manual GC allocations (for whatever reason), how can we
> later tell the GC what destructor to call?

Yes, this does work for arrays of structs. Provided that you've passed 
in the type info for the struct when doing the manual allocation, it 
should call the destructor without anything extra needing to be done on 
the user's part.

 > These questions combined are really aimed at Appender: I'm curious at if
 > and how any changes will have to be made to it.

Appender already uses the type info's destroy, so it shouldn't have any 
issues, as I already had to account for that.

 > Also question: Will this play nice wit exiting code that manually
 > destroys GC allocated structs?

As I mentioned elsewhere, as long as the existing code is calling 
destroy, and not calling the finalizer directly, then yes, it will play 
nice, and only call the finalizer once.


More information about the Digitalmars-d mailing list