Skip to content

Commit

Permalink
Add example for r2pipe-ffi
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed May 3, 2024
1 parent 1e384bd commit b998565
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions dart/r2pipe-ffi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,29 @@ typedef RCoreNew = ffi.Pointer Function();
typedef RCoreFreeFunc = ffi.Void Function(ffi.Pointer);
typedef RCoreFree = void Function(ffi.Pointer);

/*
https://pub.dev/packages/ffi/example
------------------------------------
import 'dart:ffi';
import 'package:ffi/ffi.dart';
void main() {
// Allocate and free some native memory with calloc and free.
final pointer = calloc<Uint8>();
pointer.value = 3;
print(pointer.value);
calloc.free(pointer);
// Use the Utf8 helper to encode zero-terminated UTF-8 strings in native memory.
final String myString = '😎👿💬';
final Pointer<Utf8> charPointer = myString.toNativeUtf8();
print('First byte is: ${charPointer.cast<Uint8>().value}');
print(charPointer.toDartString());
calloc.free(charPointer);
}
*/

void main() {
print('Hello Radare2 from Dart!');
Expand Down

0 comments on commit b998565

Please sign in to comment.