|
From: <ma...@us...> - 2007-04-19 22:34:02
|
Revision: 2772
http://svn.sourceforge.net/java-game-lib/?rev=2772&view=rev
Author: matzon
Date: 2007-04-19 15:18:16 -0700 (Thu, 19 Apr 2007)
Log Message:
-----------
using NewStringNativeWithLength
Modified Paths:
--------------
trunk/LWJGL/src/native/common/common_tools.c
trunk/LWJGL/src/native/common/common_tools.h
Modified: trunk/LWJGL/src/native/common/common_tools.c
===================================================================
--- trunk/LWJGL/src/native/common/common_tools.c 2007-04-19 12:00:40 UTC (rev 2771)
+++ trunk/LWJGL/src/native/common/common_tools.c 2007-04-19 22:18:16 UTC (rev 2772)
@@ -195,11 +195,11 @@
* match GLuchar and ALuchar types
*/
jstring NewStringNativeUnsigned(JNIEnv *env, const unsigned char *str) {
- return NewStringNative(env, (const char *)str);
+ return NewStringNativeWithLength(env, (const char *)str, strlen((const char *)str));
}
// creates locale specific string
-jstring NewStringNative(JNIEnv *env, const char *str) {
+jstring NewStringNativeWithLength(JNIEnv *env, const char *str, int length) {
jclass jcls_str;
jmethodID jmethod_str;
jstring result;
@@ -221,10 +221,10 @@
if ((*env)->EnsureLocalCapacity(env,2) < 0) {
return NULL; /* out of memory error */
}
- len = strlen(str);
- bytes = (*env)->NewByteArray(env,len);
+
+ bytes = (*env)->NewByteArray(env,length);
if (bytes != NULL) {
- (*env)->SetByteArrayRegion(env,bytes, 0, len, (jbyte *)str);
+ (*env)->SetByteArrayRegion(env,bytes, 0, length, (jbyte *)str);
result = (jstring)(*env)->NewObject(env,jcls_str, jmethod_str, bytes);
(*env)->DeleteLocalRef(env,bytes);
return result;
@@ -289,7 +289,7 @@
}
bool getBooleanProperty(JNIEnv *env, const char* propertyName) {
- jstring property = NewStringNative(env, propertyName);
+ jstring property = NewStringNativeWithLength(env, propertyName, strlen(propertyName));
jclass org_lwjgl_LWJGLUtil_class;
jmethodID getBoolean;
if (property == NULL)
Modified: trunk/LWJGL/src/native/common/common_tools.h
===================================================================
--- trunk/LWJGL/src/native/common/common_tools.h 2007-04-19 12:00:40 UTC (rev 2771)
+++ trunk/LWJGL/src/native/common/common_tools.h 2007-04-19 22:18:16 UTC (rev 2772)
@@ -138,7 +138,7 @@
extern void printfDebug(const char *format, ...);
extern bool getBooleanProperty(JNIEnv *env, const char* propertyName);
extern char * GetStringNativeChars(JNIEnv *env, jstring jstr);
-extern jstring NewStringNative(JNIEnv *env, const char *str);
+extern jstring NewStringNativeWithLength(JNIEnv *env, const char *str, int length);
extern jstring NewStringNativeUnsigned(JNIEnv *env, const unsigned char *str);
extern jobject newJavaManagedByteBuffer(JNIEnv *env, const int size);
extern bool positionBuffer(JNIEnv *env, jobject buffer, jint position);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|