Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extern "C"
- JNIEXPORT void JNICALL
- Java_com_ihorkucherenko_storage_Store_setString(
- JNIEnv* pEnv,
- jobject pThis,
- jstring pKey,
- jstring pString) {
- // Turns the Java string into a temporary C string.
- StoreEntry* entry = allocateEntry(pEnv, &gStore, pKey);
- if (entry != NULL) {
- entry->mType = StoreType_String;
- // Copy the temporary C string into its dynamically allocated
- // final location. Then releases the temporary string.
- jsize stringLength = pEnv->GetStringUTFLength(pString);
- entry->mValue.mString = new char[stringLength + 1];
- // Directly copies the Java String into our new C buffer.
- pEnv->GetStringUTFRegion(pString, 0, stringLength, entry->mValue.mString);
- // Append the null character for string termination.
- entry->mValue.mString[stringLength] = '\0';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement