I wonder if this could cause a problem given I’m destroying the instance while calling a method (destroy
) on one of its fields (allocator
).
// self is a *Self (this is at the end of a deinit method)
self.allocator.destroy(self);
I wonder if this could cause a problem given I’m destroying the instance while calling a method (destroy
) on one of its fields (allocator
).
// self is a *Self (this is at the end of a deinit method)
self.allocator.destroy(self);
Should be fine.
allocator.free
internally calls self.vtable.free(self.ptr, ...)
which should always pass the self.ptr
by value.
So it won’t keep a hidden reference the self.allocator
memory during freeing.