takeHandle function

int takeHandle(
  1. Pointer<Void> fn(
    1. Pointer<Uint64> out
    ),
  2. String context
)

Run fn with a zeroed uint64_t *out_handle, expectAimuxError the returned error, and hand back the handle.

Implementation

int takeHandle(
    Pointer<Void> Function(Pointer<Uint64> out) fn, String context) {
  final out = calloc<Uint64>();
  try {
    expectAimuxError(fn(out), context);
    return out.value;
  } finally {
    calloc.free(out);
  }
}