Skip to content
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

Added finalize to TableQuery #102

Merged
merged 2 commits into from
Sep 6, 2013
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ _ReSharper*/
/test_output

.DS_Store

.idea
*.iml

*.lock

Expand Down
13 changes: 13 additions & 0 deletions tightdb-java-core/src/main/java/com/tightdb/TableQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ public TableQuery(long nativeQueryPtr, boolean immutable){
this.nativePtr = nativeQueryPtr;
}

public void finalize() {
close();
}

private void close() {
if (nativePtr == 0) {
return;
}
nativeClose(nativePtr);
nativePtr = 0;
}
protected native void nativeClose(long nativeQueryPtr);

// Query TableView
public TableQuery tableview(TableView tv){
nativeTableview(nativePtr, tv.nativePtr);
Expand Down
5 changes: 5 additions & 0 deletions tightdb_jni/src/com_tightdb_TableQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ inline Table* Ref2Ptr(TableRef tableref)
return &*tableref;
}

JNIEXPORT void JNICALL Java_com_tightdb_TableQuery_nativeClose(JNIEnv * env, jobject, jlong nativeQueryPtr) {
Query* query = Q(nativeQueryPtr);
delete query;
}

// Integer

JNIEXPORT void JNICALL Java_com_tightdb_TableQuery_nativeEqual__JJJ(
Expand Down
8 changes: 8 additions & 0 deletions tightdb_jni/src/com_tightdb_TableQuery.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.