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

Method appendDataWithKey

Core/MMKV_OSX.cpp:400–417  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

398# ifndef MMKV_DISABLE_CRYPT
399
400pair<bool, KeyValueHolder>
401MMKV::appendDataWithKey(const MMBuffer &data, MMKVKey_t key, const KeyValueHolderCrypt &kvHolder, bool isDataHolder) {
402 if (kvHolder.type != KeyValueHolderType_Offset) {
403 return appendDataWithKey(data, key, isDataHolder);
404 }
405 SCOPED_LOCK(m_exclusiveProcessLock);
406
407 uint32_t keyLength = kvHolder.keySize;
408 // size needed to encode the key
409 size_t rawKeySize = keyLength + pbRawVarint32Size(keyLength);
410
411 auto basePtr = (uint8_t *) m_file->getMemory() + Fixed32Size;
412 MMBuffer keyData(rawKeySize);
413 AESCrypt decrypter = m_crypter->cloneWithStatus(kvHolder.cryptStatus);
414 decrypter.decrypt(basePtr + kvHolder.offset, keyData.getPtr(), rawKeySize);
415
416 return doAppendDataWithKey(data, keyData, isDataHolder, keyLength);
417}
418
419pair<bool, KeyValueHolder>
420MMKV::overrideDataWithKey(const MMBuffer &data, MMKVKey_t key, const KeyValueHolderCrypt &kvHolder, bool isDataHolder) {

Callers

nothing calls this directly

Calls 4

getMemoryMethod · 0.80
cloneWithStatusMethod · 0.80
decryptMethod · 0.80
pbRawVarint32SizeFunction · 0.70

Tested by

no test coverage detected