This repository has been archived by the owner on Jan 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
[Feature] use
like function for temporory native malloc/calloc object
#86
Comments
Hey, please take a look at the // To ensure resources are freed, wrap them in a [using] call.
using((Pool pool) {
final p = pool<Int64>(2);
// Do something with p.
// p is automatically `free`d at the end of this scope.
}); Your could would probably be something such as: final descriptor = using((Pool pool) {
final nativeUtf8 = path.toNativeUtf8(pool);
return _libc.open2(nativeUtf8.cast(), O_RDWR);
} Please let me know if you find that sample useful, I could merge it to this package. |
It helps a lot. Sunbreak/logic_conf.dart#8 I'll appreciate if we could merge |
Done by #103? |
Indeed. |
Is this documented anywhere? I had to go searching through issues to find this feature. I didn't think to look at the API reference because the README points to another website. Perhaps a brief overview of the features provided by this package could be added to the README? |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
It is quit easy to forget to free memory from
toNativeUtf8
andtoNativeUtf16
Sunbreak/logic_conf.dart@956ac5a
Could we have some Kolin's
use
-like statement?https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/use.html
Or similiar ones:
The text was updated successfully, but these errors were encountered: