1322 jboolean *isCopy)) |
1322 jboolean *isCopy)) |
1323 functionEnter(thr); |
1323 functionEnter(thr); |
1324 IN_VM( |
1324 IN_VM( |
1325 checkString(thr, str); |
1325 checkString(thr, str); |
1326 ) |
1326 ) |
|
1327 jchar* newResult = NULL; |
1327 const jchar *result = UNCHECKED()->GetStringChars(env,str,isCopy); |
1328 const jchar *result = UNCHECKED()->GetStringChars(env,str,isCopy); |
1328 assert (isCopy == NULL || *isCopy == JNI_TRUE, "GetStringChars didn't return a copy as expected"); |
1329 assert (isCopy == NULL || *isCopy == JNI_TRUE, "GetStringChars didn't return a copy as expected"); |
1329 |
1330 if (result != NULL) { |
1330 size_t len = UNCHECKED()->GetStringLength(env,str) + 1; // + 1 for NULL termination |
1331 size_t len = UNCHECKED()->GetStringLength(env,str) + 1; // + 1 for NULL termination |
1331 jint* tagLocation = (jint*) AllocateHeap(len * sizeof(jchar) + sizeof(jint), mtInternal); |
1332 jint* tagLocation = (jint*) AllocateHeap(len * sizeof(jchar) + sizeof(jint), mtInternal); |
1332 *tagLocation = STRING_TAG; |
1333 *tagLocation = STRING_TAG; |
1333 jchar* newResult = (jchar*) (tagLocation + 1); |
1334 newResult = (jchar*) (tagLocation + 1); |
1334 memcpy(newResult, result, len * sizeof(jchar)); |
1335 memcpy(newResult, result, len * sizeof(jchar)); |
1335 // Avoiding call to UNCHECKED()->ReleaseStringChars() since that will fire unexpected dtrace probes |
1336 // Avoiding call to UNCHECKED()->ReleaseStringChars() since that will fire unexpected dtrace probes |
1336 // Note that the dtrace arguments for the allocated memory will not match up with this solution. |
1337 // Note that the dtrace arguments for the allocated memory will not match up with this solution. |
1337 FreeHeap((char*)result); |
1338 FreeHeap((char*)result); |
1338 |
1339 } |
1339 functionExit(env); |
1340 functionExit(env); |
1340 return newResult; |
1341 return newResult; |
1341 JNI_END |
1342 JNI_END |
1342 |
1343 |
1343 JNI_ENTRY_CHECKED(void, |
1344 JNI_ENTRY_CHECKED(void, |
1392 jboolean *isCopy)) |
1393 jboolean *isCopy)) |
1393 functionEnter(thr); |
1394 functionEnter(thr); |
1394 IN_VM( |
1395 IN_VM( |
1395 checkString(thr, str); |
1396 checkString(thr, str); |
1396 ) |
1397 ) |
|
1398 char* newResult = NULL; |
1397 const char *result = UNCHECKED()->GetStringUTFChars(env,str,isCopy); |
1399 const char *result = UNCHECKED()->GetStringUTFChars(env,str,isCopy); |
1398 assert (isCopy == NULL || *isCopy == JNI_TRUE, "GetStringUTFChars didn't return a copy as expected"); |
1400 assert (isCopy == NULL || *isCopy == JNI_TRUE, "GetStringUTFChars didn't return a copy as expected"); |
1399 |
1401 if (result != NULL) { |
1400 size_t len = strlen(result) + 1; // + 1 for NULL termination |
1402 size_t len = strlen(result) + 1; // + 1 for NULL termination |
1401 jint* tagLocation = (jint*) AllocateHeap(len + sizeof(jint), mtInternal); |
1403 jint* tagLocation = (jint*) AllocateHeap(len + sizeof(jint), mtInternal); |
1402 *tagLocation = STRING_UTF_TAG; |
1404 *tagLocation = STRING_UTF_TAG; |
1403 char* newResult = (char*) (tagLocation + 1); |
1405 newResult = (char*) (tagLocation + 1); |
1404 strcpy(newResult, result); |
1406 strcpy(newResult, result); |
1405 // Avoiding call to UNCHECKED()->ReleaseStringUTFChars() since that will fire unexpected dtrace probes |
1407 // Avoiding call to UNCHECKED()->ReleaseStringUTFChars() since that will fire unexpected dtrace probes |
1406 // Note that the dtrace arguments for the allocated memory will not match up with this solution. |
1408 // Note that the dtrace arguments for the allocated memory will not match up with this solution. |
1407 FreeHeap((char*)result, mtInternal); |
1409 FreeHeap((char*)result, mtInternal); |
1408 |
1410 } |
1409 functionExit(env); |
1411 functionExit(env); |
1410 return newResult; |
1412 return newResult; |
1411 JNI_END |
1413 JNI_END |
1412 |
1414 |
1413 JNI_ENTRY_CHECKED(void, |
1415 JNI_ENTRY_CHECKED(void, |