Skip to content

fix Memory leak #102 #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/build_test_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,10 @@ jobs:
submodules: true
- name: setup
run: |
brew install --force --overwrite ninja ccache ffmpeg@6 nasm conan
brew install --force --overwrite ninja ccache ffmpeg@6 nasm [email protected]
brew link --overwrite ffmpeg@6
brew link --overwrite [email protected]
brew install --force --overwrite conan
conan profile detect -f
cd ${{github.workspace}}
- name: build
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.10

- Fix: memory leak caused by cvstatus

## 1.0.9

- Fix: free smart pointer
Expand Down
2 changes: 1 addition & 1 deletion binary.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.9
1.0.10
21 changes: 11 additions & 10 deletions lib/src/core/base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,17 @@ abstract class CvStruct<T extends ffi.Struct> extends ICvStruct<T> with Equatabl
CvStruct.fromPointer(super.ptr) : super.fromPointer();
}

void cvRun(CvStatus Function() func) {
final status = func();
if (status.code != 0) {
throw CvException(
status.code,
msg: status.msg.cast<Utf8>().toDartString(),
file: status.file.cast<Utf8>().toDartString(),
func: status.func.cast<Utf8>().toDartString(),
line: status.line,
);
void cvRun(ffi.Pointer<CvStatus> Function() func) {
final s = func();
final code = s.ref.code;
// String err = s.ref.err.cast<Utf8>().toDartString();
final msg = s.ref.msg.cast<Utf8>().toDartString();
final file = s.ref.file.cast<Utf8>().toDartString();
final funcName = s.ref.func.cast<Utf8>().toDartString();
final line = s.ref.line;
CFFI.CvStatus_Close(s);
if (code != 0) {
throw CvException(code, msg: msg, file: file, func: funcName, line: line);
}
}

Expand Down
Loading
Loading