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

Function encodeBytes_2

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

Source from the content-addressed store, hash-verified

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);
697 if (kv && oKey) {
698 string key = jstring2string(env, oKey);
699 if (oValue) {
700 MMBuffer value(0);
701 {
702 jsize len = env->GetArrayLength(oValue);
703 void *bufferPtr = env->GetPrimitiveArrayCritical(oValue, nullptr);
704 if (bufferPtr) {
705 value = MMBuffer(bufferPtr, len);
706 env->ReleasePrimitiveArrayCritical(oValue, bufferPtr, JNI_ABORT);
707 } else {
708 MMKVError("fail to get array: %s=%p", key.c_str(), oValue);
709 }
710 }
711 return (jboolean) kv->set(value, key, (uint32_t) expiration);
712 } else {
713 kv->removeValueForKey(key);
714 return (jboolean) true;
715 }
716 }
717 return (jboolean) false;
718}
719
720MMKV_JNI jbyteArray decodeBytes(JNIEnv *env, jobject obj, jlong handle, jstring oKey) {
721 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