-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[breaking change] Add an nullable nativeFree
getter to Allocator
#55571
Comments
That should be either ImpactOlder versions of Most people should just be able to update their |
Original PR adding the @dcharkes Thanks, edited the Impact section. |
@vsmenon @leonsenft @Hixie breaking change request. |
no objection, sorry for the delay |
Friendly holiday bump for @vsmenon and @leonsenft. |
lgtm |
1 similar comment
lgtm |
@HosseinYousefi this breaking change request has been approved |
Change Intent
Add a nullable
nativeFree
getter toAllocator
to ease working with native finalizers.Justification
This would simplify the API for adding native finalizers. The
allocator
argument can be defaulted to e.g.malloc
, and methods using this allocator could attach native finalizers to the objects allocated usingallocator.nativeFree
if it's notnull
.For example:
Impact
We provide some allocators in
package:ffi
, but a search here on GitHub shows that not many people implementAllocator
themselves.Older versions of
package:ffi
will stop working on newer SDKs, and we don't have a way of retroactively adding an SDK upper bound to those versions.Most people should just be able to update their
package:ffi
, but apps that have pinned their deps might see compile errors.Mitigation
package:ffi
'sMallocAllocator
andCallocAllocator
already havenativeFree
getters.We can safely add
Pointer<NativeFinalizerFunction>? get nativeFree => null
to all the existingAllocator
subclasses that have a no-opfree
likeArena
.Alternatives Considered
We could introduce a
NativeFreeableAllocator implements Allocator
that has anativeFree
getter, and this was the original design for this PR: dart-archive/ffi#203However @lrhn raised some issues with this design here and here.
Change Timeline
No response
Associated CLs
No response
The text was updated successfully, but these errors were encountered: