MCPcopy Create free account
hub / github.com/Tencent/MMKV / encodeBytes

Function encodeBytes

Android/MMKV/mmkv/src/main/cpp/native-bridge.cpp:670–693  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

668}
669
670MMKV_JNI jboolean encodeBytes(JNIEnv *env, jobject, jlong handle, jstring oKey, jbyteArray oValue) {
671 MMKV *kv = reinterpret_cast<MMKV *>(handle);
672 if (kv && oKey) {
673 string key = jstring2string(env, oKey);
674 if (oValue) {
675 MMBuffer value(0);
676 {
677 jsize len = env->GetArrayLength(oValue);
678 void *bufferPtr = env->GetPrimitiveArrayCritical(oValue, nullptr);
679 if (bufferPtr) {
680 value = MMBuffer(bufferPtr, len);
681 env->ReleasePrimitiveArrayCritical(oValue, bufferPtr, JNI_ABORT);
682 } else {
683 MMKVError("fail to get array: %s=%p", key.c_str(), oValue);
684 }
685 }
686 return (jboolean) kv->set(value, key);
687 } else {
688 kv->removeValueForKey(key);
689 return (jboolean) true;
690 }
691 }
692 return (jboolean) false;
693}
694
695MMKV_JNI jboolean encodeBytes_2(JNIEnv *env, jobject, jlong handle, jstring oKey, jbyteArray oValue, jint expiration) {
696 MMKV *kv = reinterpret_cast<MMKV *>(handle);

Callers

nothing calls this directly

Calls 4

jstring2stringFunction · 0.70
MMBufferFunction · 0.50
setMethod · 0.45
removeValueForKeyMethod · 0.45

Tested by

no test coverage detected