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

Function fastRemoveCornetSizeTest

POSIX/demo/demo.cpp:387–409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

385}
386
387void fastRemoveCornetSizeTest() {
388 string aesKey = "aes";
389 auto mmkv = MMKV::mmkvWithID("fastRemoveCornerSize", MMKV_MULTI_PROCESS, &aesKey);
390 mmkv->clearAll();
391 auto size = getpagesize() - 4;
392 size -= 4;
393 string key = "key";
394 auto keySize = 3 + 1;
395 size -= keySize;
396 auto valueSize = 3;
397 size -= valueSize;
398 size -= (keySize + 1); // total size of fast remove
399 size /= 16;
400 mmkv::MMBuffer value(size);
401 auto ptr = (char *) value.getPtr();
402 for (size_t i = 0; i < value.length(); i++) {
403 ptr[i] = 'A';
404 }
405 for (int i = 0; i < 16; i++) {
406 mmkv->set(value, key); // when a full write back is occur, here's corruption happens
407 mmkv->removeValueForKey(key);
408 }
409}
410
411void testClearEmptyMMKV() {
412 auto mmkv = MMKV::mmkvWithID("emptyMMKV");

Callers

nothing calls this directly

Calls 5

mmkvWithIDFunction · 0.85
getpagesizeFunction · 0.85
clearAllMethod · 0.45
setMethod · 0.45
removeValueForKeyMethod · 0.45

Tested by

no test coverage detected