mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-05 20:59:08 -04:00
refactor!: use Finalizer
to automatically free allocated memory for objects (#48)
BREAKING CHANGE: signature change for remote and repository callbacks during repository clone operation.
This commit is contained in:
parent
94c40f9a94
commit
a3213a88a2
103 changed files with 2278 additions and 2595 deletions
|
@ -32,13 +32,15 @@ Pointer<git_describe_result> commit({
|
|||
|
||||
final error = libgit2.git_describe_commit(out, commitPointer.cast(), opts);
|
||||
|
||||
final result = out.value;
|
||||
|
||||
calloc.free(out);
|
||||
calloc.free(opts);
|
||||
|
||||
if (error < 0) {
|
||||
calloc.free(out);
|
||||
throw LibGit2Error(libgit2.git_error_last());
|
||||
} else {
|
||||
return out.value;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,13 +70,15 @@ Pointer<git_describe_result> workdir({
|
|||
|
||||
final error = libgit2.git_describe_workdir(out, repo, opts);
|
||||
|
||||
final result = out.value;
|
||||
|
||||
calloc.free(out);
|
||||
calloc.free(opts);
|
||||
|
||||
if (error < 0) {
|
||||
calloc.free(out);
|
||||
throw LibGit2Error(libgit2.git_error_last());
|
||||
} else {
|
||||
return out.value;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,8 +110,9 @@ String format({
|
|||
|
||||
final result = out.ref.ptr.cast<Utf8>().toDartString(length: out.ref.size);
|
||||
|
||||
calloc.free(opts);
|
||||
libgit2.git_buf_dispose(out);
|
||||
calloc.free(out);
|
||||
calloc.free(opts);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue