From 2530b450056d4e8df8fff27c9c62071461aa239b Mon Sep 17 00:00:00 2001 From: Caspian Rychlik-Prince Date: Sun, 24 Nov 2002 22:46:39 +0000 Subject: [PATCH] Fixed array allocation syntax error and removed std namespace for VC6.0 users --- ...g_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp | 13 +++++++++++-- ...org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp | 15 ++++++++++++--- ...wjgl_Math_MatrixOpNormalise_MatrixOpDirect.cpp | 2 +- ..._lwjgl_Math_MatrixOpNormalise_MatrixOpSafe.cpp | 2 +- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/native/win32/org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp b/src/native/win32/org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp index 53bc0d60..36dabe13 100644 --- a/src/native/win32/org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp +++ b/src/native/win32/org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp @@ -65,7 +65,10 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpInvert_00024MatrixOpDire jboolean transposeDest ) { - if (transposeSource == transposeDest) + static float * temp_matrix = 0; + static int temp_matrix_size = 0; + + if (transposeSource == transposeDest) { transposeSource = JNI_FALSE; transposeDest = JNI_FALSE; @@ -85,7 +88,13 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpInvert_00024MatrixOpDire float * srcMatrix, * destMatrix; int temp_side = source.width-1; - float temp_matrix [temp_side*temp_side]; + + if (temp_matrix_size < temp_side) { + if (temp_matrix) + delete[] temp_matrix; + temp_matrix = new float[temp_side * temp_side]; + temp_matrix_size = temp_side; + } for (int i = 0; i < source.elements; i++) { diff --git a/src/native/win32/org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp b/src/native/win32/org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp index ba4f0821..1f06a495 100644 --- a/src/native/win32/org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp +++ b/src/native/win32/org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp @@ -68,7 +68,10 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpInvert_00024MatrixOpSafe ) { - if (transposeSource == transposeDest) + static float * temp_matrix = 0; + static int temp_matrix_size = 0; + + if (transposeSource == transposeDest) { transposeSource = JNI_FALSE; transposeDest = JNI_FALSE; @@ -85,9 +88,15 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpInvert_00024MatrixOpSafe float * srcMatrix, * destMatrix; int temp_side = source.width-1; - float temp_matrix [temp_side*temp_side]; - for (int i = 0; i < source.elements; i++) + if (temp_matrix_size < temp_side) { + if (temp_matrix) + delete[] temp_matrix; + temp_matrix = new float[temp_side * temp_side]; + temp_matrix_size = temp_side; + } + + for (int i = 0; i < source.elements; i++) { srcMatrix = source.nextMatrix(); destMatrix = dest.nextMatrix(); diff --git a/src/native/win32/org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect.cpp b/src/native/win32/org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect.cpp index 9667a67b..b4e2c05f 100644 --- a/src/native/win32/org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect.cpp +++ b/src/native/win32/org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect.cpp @@ -44,7 +44,7 @@ #include "MatrixOpCommon.h" #include -using namespace std; +//using namespace std; /* * Class: org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect diff --git a/src/native/win32/org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe.cpp b/src/native/win32/org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe.cpp index faa2d4cf..7f3a6241 100644 --- a/src/native/win32/org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe.cpp +++ b/src/native/win32/org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe.cpp @@ -44,7 +44,7 @@ #include "MatrixOpCommon.h" #include -using namespace std; +//using namespace std; /* * Class: org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe