Fix early finalization of function.

Previously, the SetFinalizer(&f, ...) call would allow f to be finalized
as soon as the pointer &f was no longer accessible (i.e. immediately
after the SetFinalizer call finished). This caused the AddressChooser to
be finalized while Java still referenced it and before it was called in
some instances.

Now a pointer to struct is returned and the finalizer is only called
after the last pointer to the struct is dropped.

MultiPart: 4/4
Change-Id: Ia1751e22a8673e4a1e72b62cd3321ce1ed84169d
2 files changed