Skip to content

Commit 7b8944a

Browse files
committed
Do not avoid copying array content for const ** arrays. Do that for * consts.
This fixes bytedeco#776 Before this change, we did not copy array contents back to the argument array for "const **" as it is regarded as immutable. But it in fact it mutable. This StackOverflow question describes it well. https://stackoverflow.com/questions/4949254/const-char-const-versus-const-char After this change, it will avoid copying if the parameter pointer itself is const.
1 parent 2fd35c6 commit 7b8944a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/main/java/org/bytedeco/javacpp/tools/Generator.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -3031,7 +3031,7 @@ void parametersAfter(MethodInformation methodInfo) {
30313031

30323032
// If const array, then use JNI_ABORT to avoid copying unmodified data back to JVM
30333033
final String releaseArrayFlag;
3034-
if (cast.contains(" const *") || cast.startsWith("(const ")) {
3034+
if (cast.contains("* const") || cast.endsWith("const)")) {
30353035
releaseArrayFlag = "JNI_ABORT";
30363036
} else {
30373037
releaseArrayFlag = "0";

0 commit comments

Comments
 (0)