ffi_helper 2.0.0+1 copy "ffi_helper: ^2.0.0+1" to clipboard
ffi_helper: ^2.0.0+1 copied to clipboard

discontinued
outdated

Utility classes to make working with Dart's FFI a little bit simpler and more efficient.

This package contains some utility classes to make working with Dart's FFI a little bit simpler and more efficient. You should be familiar with Dart's FFI. You find practical code examples in the api-documentation.

All classes are generic and take a NativeType and its associated List<int> type like Uint8List. You can specialize each class by extending it like class Uint8Array extends Array<Uint8,Uint8List>. Because working with Uint8 data is so common, there already is a specialized Uint8 variant of each utility class.

Working with pointers can be tricky because they don't know their size, and getting the size wrong can lead to undefined behavior and hard to locate bugs. The Array class can alleviate that situation, making working with arrays simpler and safer.

Often multiple parts of your code could share a single memory buffer, but that always rises the question of ownership: who has to clean up and when? The reference counted SharedArray solves this problem.

When you have to make many little memory allocations, consider using Arena to do arena / region-based allocation. Arena lets you allocate a large chunk of memory which can then be sliced into smaller views. The allocated memory can then be released in one operation. This kind of memory management can lead to drastic performance improvements and fewer bugs.

2
likes
0
pub points
13%
popularity

Publisher

unverified uploader

Utility classes to make working with Dart's FFI a little bit simpler and more efficient.

Homepage

License

unknown (LICENSE)

Dependencies

ffi

More

Packages that depend on ffi_helper