I have a Java object (created from a Java class generated by SWIG) that when it is about to terminate/finalize, I would like to call a C function to release some allocated resources by the C side of my program.
Basically, I would like to know how to extend the following Java method (generated by SWIG) with a call to a C function to release resources:
public synchronized void delete() {
if (swigCPtr != 0) {
if (swigCMemOwn) {
swigCMemOwn = false;
TestJNI.delete_Pool(swigCPtr);
TestJNI.releaseResource(swigCPtr); // call C function to release resources
}
swigCPtr = 0;
}
}
Could you please tell how to update the SWIG interface file so that it can include the line (with a comment) when generating the Java wrapper?