refactor: revert 'use ffi Arena for resource management'

This commit is contained in:
Aleksey Kulikov 2021-08-27 15:05:05 +03:00
parent 6a097c1841
commit a78c38d8e3
9 changed files with 588 additions and 620 deletions

View file

@ -42,17 +42,17 @@ Pointer<git_oid> fromSHA(String hex) {
///
/// Throws a [LibGit2Error] if error occured.
String toSHA(Pointer<git_oid> id) {
return using((Arena arena) {
final out = arena<Int8>(40);
final error = libgit2.git_oid_fmt(out, id);
final result = out.cast<Utf8>().toDartString(length: 40);
final out = calloc<Int8>(40);
final error = libgit2.git_oid_fmt(out, id);
final result = out.cast<Utf8>().toDartString(length: 40);
if (error < 0) {
throw LibGit2Error(libgit2.git_error_last());
} else {
return result;
}
});
calloc.free(out);
if (error < 0) {
throw LibGit2Error(libgit2.git_error_last());
} else {
return result;
}
}
/// Compare two oid structures.