takeString function
Run fn with a NULL char **out_json, expectAimuxError the returned error,
copy the owned C string out and free it.
Implementation
String takeString(
Pointer<Void> Function(Pointer<Pointer<Utf8>> out) fn, String context) {
final out = calloc<Pointer<Utf8>>();
try {
expectAimuxError(fn(out), context);
final p = out.value;
if (p == nullptr) throw StateError('aimux ffi: $context: NULL result');
try {
return p.toDartString();
} finally {
aimuxFreeString(p);
}
} finally {
calloc.free(out);
}
}