mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-05 04:39:07 -04:00
refactor: revert 'use ffi Arena for resource management'
This commit is contained in:
parent
6a097c1841
commit
a78c38d8e3
9 changed files with 588 additions and 620 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue