/[classpath]/classpath/native/jni/classpath/jcl.c
ViewVC logotype

Diff of /classpath/native/jni/classpath/jcl.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by mark, Tue Jan 22 22:27:02 2002 UTC revision 1.3 by rupp, Wed Jul 16 09:39:48 2003 UTC
# Line 35  this exception to your version of the li Line 35  this exception to your version of the li
35  obligated to do so.  If you do not wish to do so, delete this  obligated to do so.  If you do not wish to do so, delete this
36  exception statement from your version. */  exception statement from your version. */
37    
38    /* do not move; needed here because of some macro definitions */
39    #include "jamaica_config.h"
40    
41    #include <stdlib.h>
42  #include <stdio.h>  #include <stdio.h>
43  #include <jcl.h>  #include <jcl.h>
 #include <malloc.h>  
44    
45  static char errstr[4098]; // this way the memory is pre-allocated, so that we do not have to worry if we are out of memory.  static char errstr[4098]; // this way the memory is pre-allocated, so that we do not have to worry if we are out of memory.
46    
# Line 91  JNIEXPORT void JNICALL JCL_free(JNIEnv * Line 94  JNIEXPORT void JNICALL JCL_free(JNIEnv *
94          }          }
95  }  }
96    
97  JNIEXPORT char * JNICALL JCL_jstring_to_cstring(JNIEnv * env, jstring s) {  JNIEXPORT const char * JNICALL JCL_jstring_to_cstring(JNIEnv * env, jstring s) {
98          char* cstr;          const char* cstr;
99          if(s == NULL) {          if(s == NULL) {
100                  JCL_ThrowException(env, "java/lang/NullPointerException","Null string");                  JCL_ThrowException(env, "java/lang/NullPointerException","Null string");
101                  return NULL;                  return NULL;
102          }          }
103          cstr = (char*)(*env)->GetStringUTFChars(env, s, NULL);          cstr = (const char*)(*env)->GetStringUTFChars(env, s, NULL);
104          if(cstr == NULL) {          if(cstr == NULL) {
105                  JCL_ThrowException(env, "java/lang/InternalError", "GetStringUTFChars() failed.");                  JCL_ThrowException(env, "java/lang/InternalError", "GetStringUTFChars() failed.");
106                  return NULL;                  return NULL;
# Line 105  JNIEXPORT char * JNICALL JCL_jstring_to_ Line 108  JNIEXPORT char * JNICALL JCL_jstring_to_
108          return cstr;          return cstr;
109  }  }
110    
111  JNIEXPORT void JNICALL JCL_free_cstring(JNIEnv * env, jstring s, char * cstr) {  JNIEXPORT void JNICALL JCL_free_cstring(JNIEnv * env, jstring s, const char * cstr) {
112          (*env)->ReleaseStringUTFChars(env, s, cstr);          (*env)->ReleaseStringUTFChars(env, s, cstr);
113  }  }
114    

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26