refactor!: use Finalizer to automatically free allocated memory for objects

BREAKING CHANGE: signature change for remote and repository callbacks
during repository clone operation.
This commit is contained in:
Aleksey Kulikov 2022-04-21 14:07:11 +03:00
parent 94c40f9a94
commit b589097c8c
73 changed files with 1073 additions and 1618 deletions

View file

@ -21,7 +21,6 @@ void main() {
});
tearDown(() {
tag.free();
repo.free();
tmpDir.deleteSync(recursive: true);
});
@ -59,9 +58,6 @@ void main() {
expect(target.message, 'add subdirectory file\n');
expect(tagger, signature);
expect(tag.toString(), contains('Tag{'));
signature.free();
target.free();
});
test('creates new annotated tag with commit as target', () {
@ -94,10 +90,6 @@ void main() {
expect(newTag.targetOid.sha, targetSHA);
expect(tagger, signature);
expect(newTagTarget.oid, target);
newTag.free();
newTagTarget.free();
signature.free();
});
test('creates new lightweight tag with commit as target', () {
@ -115,8 +107,6 @@ void main() {
expect(newTag.shorthand, tagName);
expect(newTag.target, target);
newTag.free();
});
test('creates new annotated tag with tree as target', () {
@ -147,10 +137,6 @@ void main() {
expect(newTag.message, message);
expect(tagger, signature);
expect(newTagTarget.oid, target);
newTag.free();
newTagTarget.free();
signature.free();
});
test('creates new lightweight tag with tree as target', () {
@ -168,8 +154,6 @@ void main() {
expect(newTag.shorthand, tagName);
expect(newTag.target, target);
newTag.free();
});
test('creates new annotated tag with blob as target', () {
@ -200,10 +184,6 @@ void main() {
expect(newTag.message, message);
expect(tagger, signature);
expect(newTagTarget.oid, target);
newTag.free();
newTagTarget.free();
signature.free();
});
test('creates new lightweight tag with blob as target', () {
@ -221,8 +201,6 @@ void main() {
expect(newTag.shorthand, tagName);
expect(newTag.target, target);
newTag.free();
});
test('creates new annotated tag with tag as target', () {
@ -252,10 +230,6 @@ void main() {
expect(newTag.message, message);
expect(tagger, signature);
expect(newTagTarget.oid, tag.oid);
newTag.free();
newTagTarget.free();
signature.free();
});
test('creates new lightweight tag with tag as target', () {
@ -272,8 +246,6 @@ void main() {
expect(newTag.shorthand, tagName);
expect(newTag.target, tag.oid);
newTag.free();
});
test(
@ -313,10 +285,6 @@ void main() {
expect(tagger, signature);
expect(newTagTarget.oid, target);
expect(repo.tags.length, equals(2));
newTag.free();
newTagTarget.free();
signature.free();
});
test(
@ -342,8 +310,6 @@ void main() {
expect(newTag.shorthand, tagName);
expect(newTag.target, target);
expect(repo.tags.length, equals(2));
newTag.free();
});
test('throws when trying to create annotated tag with invalid name', () {
@ -420,5 +386,10 @@ void main() {
throwsA(isA<LibGit2Error>()),
);
});
test('manually releases allocated memory', () {
tag = Tag.lookup(repo: repo, oid: tagOid);
expect(() => tag.free(), returnsNormally);
});
});
}