I want to write a Java wrapper to a native library (with BridJ). The method I want to wrap takes a struct of operations (callbacks):
typedef struct _operations {
int (*op1) (int, ...);
int (*op2) (float, ...);
} operations;
int method(*operations ops);
The operations should obviously be written in Java, so method
calls back to Java space (using BridJ's Callback mechanism).
However, after executing the Java callbacks and returning to method
, local variables in the C code have changed:
int method(*operations ops) {
void* uselesspointer;
DbgPrint("useless pointer before callback is %d\n", uselesspointer);
// prints x
// execute callbacks in Java here
DbgPrint("useless pointer after callback is %d\n", uselesspointer);
// prints something different from x
}
How can I prevent this from happening?
// see https://github.com/Maxhy/dokany/issues/7 for details
// edit thats interesting: the offset of useless pointer seems to be constant, in my application the second debug message is always "192" instead of "0"