mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-05 04:39:07 -04:00
refactor(repository)!: use Finalizer
to automatically free allocated memory (#51)
BREAKING CHANGE: Return value of identity getter changed from Map<String, String> to Identity
This commit is contained in:
parent
aef440e345
commit
4e55d0f06c
43 changed files with 109 additions and 151 deletions
|
@ -321,17 +321,19 @@ void setIdentity({
|
|||
}
|
||||
|
||||
/// Retrieve the configured identity to use for reflogs.
|
||||
Map<String, String> identity(Pointer<git_repository> repo) {
|
||||
///
|
||||
/// Returns list with name and email respectively.
|
||||
List<String> identity(Pointer<git_repository> repo) {
|
||||
final name = calloc<Pointer<Int8>>();
|
||||
final email = calloc<Pointer<Int8>>();
|
||||
libgit2.git_repository_ident(name, email, repo);
|
||||
final identity = <String, String>{};
|
||||
final identity = <String>[];
|
||||
|
||||
if (name.value == nullptr && email.value == nullptr) {
|
||||
return identity;
|
||||
} else {
|
||||
identity[name.value.cast<Utf8>().toDartString()] =
|
||||
email.value.cast<Utf8>().toDartString();
|
||||
identity.add(name.value.cast<Utf8>().toDartString());
|
||||
identity.add(email.value.cast<Utf8>().toDartString());
|
||||
}
|
||||
|
||||
calloc.free(name);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue