snazzy-d/sdc

Add support for finalizer in the GC

Closed this issue · 0 comments

The D GC support allocation that needs some special form of finalization. Contrary to appendable allocation as in #266 , we expect finalizable ones to be unfrequent.

A finalizable allocation will contain a function pointer to the finalizer then the allocation that is returned for the user. When the allocation is destroyed, the finalizer is called with the base pointer of the allocation and the size for appendable allocations (as to enable arrays of element to be destoyed properly for instance).

The API of the GC needs to be extended with a method that does not simply frees an allocation, but destroys it (meaning calling the finalizer if necessary, then free).