| 137 | } |
| 138 | |
| 139 | static void utf8JavaByteArrayToUtf8Bytes(JNIEnv *env, jbyteArray utf8bytes, char** bytes, int* nbytes) |
| 140 | { |
| 141 | jsize utf8bytes_length; |
| 142 | char* buf; |
| 143 | |
| 144 | *bytes = NULL; |
| 145 | if (nbytes) *nbytes = 0; |
| 146 | |
| 147 | if (!utf8bytes) |
| 148 | { |
| 149 | return; |
| 150 | } |
| 151 | |
| 152 | utf8bytes_length = (*env)->GetArrayLength(env, (jarray) utf8bytes); |
| 153 | |
| 154 | buf = (char*) malloc(utf8bytes_length + 1); |
| 155 | if (!buf) |
| 156 | { |
| 157 | throwex_outofmemory(env); |
| 158 | return; |
| 159 | } |
| 160 | |
| 161 | (*env)->GetByteArrayRegion(env, utf8bytes, 0, utf8bytes_length, (jbyte*)buf); |
| 162 | |
| 163 | buf[utf8bytes_length] = '\0'; |
| 164 | |
| 165 | *bytes = buf; |
| 166 | if (nbytes) *nbytes = (int) utf8bytes_length; |
| 167 | } |
| 168 | |
| 169 | static jbyteArray stringToUtf8ByteArray(JNIEnv *env, jstring str) |
| 170 | { |
no test coverage detected