mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-05 12:49: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
|
@ -19,27 +19,25 @@ Object? getAttribute({
|
|||
final nameC = name.toNativeUtf8().cast<Int8>();
|
||||
libgit2.git_attr_get(out, repoPointer, flags, pathC, nameC);
|
||||
|
||||
final result = out.value;
|
||||
|
||||
calloc.free(out);
|
||||
calloc.free(pathC);
|
||||
calloc.free(nameC);
|
||||
|
||||
final attributeValue = libgit2.git_attr_value(out.value);
|
||||
final attributeValue = libgit2.git_attr_value(result);
|
||||
|
||||
if (attributeValue == git_attr_value_t.GIT_ATTR_VALUE_UNSPECIFIED) {
|
||||
calloc.free(out);
|
||||
return null;
|
||||
}
|
||||
if (attributeValue == git_attr_value_t.GIT_ATTR_VALUE_TRUE) {
|
||||
calloc.free(out);
|
||||
return true;
|
||||
}
|
||||
if (attributeValue == git_attr_value_t.GIT_ATTR_VALUE_FALSE) {
|
||||
calloc.free(out);
|
||||
return false;
|
||||
}
|
||||
if (attributeValue == git_attr_value_t.GIT_ATTR_VALUE_STRING) {
|
||||
final result = out.value.cast<Utf8>().toDartString();
|
||||
calloc.free(out);
|
||||
return result;
|
||||
return result.cast<Utf8>().toDartString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue