Skip to content

Commit dcb17be

Browse files
authored
Merge pull request #105 from rainyl/issue102-main
fix Memory leak #102
2 parents 3aff845 + 4d42129 commit dcb17be

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+6453
-5751
lines changed

.github/workflows/build_test_release.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,10 @@ jobs:
172172
submodules: true
173173
- name: setup
174174
run: |
175-
brew install --force --overwrite ninja ccache ffmpeg@6 nasm conan
175+
brew install --force --overwrite ninja ccache ffmpeg@6 nasm [email protected]
176176
brew link --overwrite ffmpeg@6
177+
brew link --overwrite [email protected]
178+
brew install --force --overwrite conan
177179
conan profile detect -f
178180
cd ${{github.workspace}}
179181
- name: build

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.0.10
2+
3+
- Fix: memory leak caused by cvstatus
4+
15
## 1.0.9
26

37
- Fix: free smart pointer

binary.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.9
1+
1.0.10

lib/src/core/base.dart

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,17 @@ abstract class CvStruct<T extends ffi.Struct> extends ICvStruct<T> with Equatabl
6262
CvStruct.fromPointer(super.ptr) : super.fromPointer();
6363
}
6464

65-
void cvRun(CvStatus Function() func) {
66-
final status = func();
67-
if (status.code != 0) {
68-
throw CvException(
69-
status.code,
70-
msg: status.msg.cast<Utf8>().toDartString(),
71-
file: status.file.cast<Utf8>().toDartString(),
72-
func: status.func.cast<Utf8>().toDartString(),
73-
line: status.line,
74-
);
65+
void cvRun(ffi.Pointer<CvStatus> Function() func) {
66+
final s = func();
67+
final code = s.ref.code;
68+
// String err = s.ref.err.cast<Utf8>().toDartString();
69+
final msg = s.ref.msg.cast<Utf8>().toDartString();
70+
final file = s.ref.file.cast<Utf8>().toDartString();
71+
final funcName = s.ref.func.cast<Utf8>().toDartString();
72+
final line = s.ref.line;
73+
CFFI.CvStatus_Close(s);
74+
if (code != 0) {
75+
throw CvException(code, msg: msg, file: file, func: funcName, line: line);
7576
}
7677
}
7778

0 commit comments

Comments
 (0)