Skip to content

Commit

Permalink
make sure DEFAULT_MMAP_SIZE is inited
Browse files Browse the repository at this point in the history
  • Loading branch information
lingol committed Mar 22, 2019
1 parent 3b2ecbe commit ef4be36
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Android/MMKV/mmkv/src/main/cpp/native-bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ extern "C" JNIEXPORT JNICALL jbyteArray Java_com_tencent_mmkv_MMKV_decodeBytes(J
if (kv && oKey) {
string key = jstring2string(env, oKey);
MMBuffer value = kv->getBytesForKey(key);
if (value.length() > 0){
if (value.length() > 0) {
jbyteArray result = env->NewByteArray(value.length());
env->SetByteArrayRegion(result, 0, value.length(), (const jbyte *) value.getPtr());
return result;
Expand Down
3 changes: 3 additions & 0 deletions iOS/MMKV/MMKV/MMKV.mm
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
id<MMKVHandler> g_callbackHandler;
bool g_isLogRedirecting = false;

int DEFAULT_MMAP_SIZE;

#define DEFAULT_MMAP_ID @"mmkv.default"
#define CRC_FILE_SIZE DEFAULT_MMAP_SIZE
#define SPECIAL_CHARACTER_DIRECTORY_NAME @"specialCharacter"
Expand Down Expand Up @@ -80,6 +82,7 @@ + (void)initialize {
g_instanceDic = [NSMutableDictionary dictionary];
g_instanceLock = [[NSRecursiveLock alloc] init];

DEFAULT_MMAP_SIZE = getpagesize();
MMKVInfo(@"pagesize:%d", DEFAULT_MMAP_SIZE);
}
}
Expand Down
2 changes: 1 addition & 1 deletion iOS/MMKV/MMKV/MemoryFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#import "LRUCache.hpp"
#import <Foundation/Foundation.h>

extern const int DEFAULT_MMAP_SIZE;
extern int DEFAULT_MMAP_SIZE;

class MemoryFile {
NSString *m_name;
Expand Down
1 change: 0 additions & 1 deletion iOS/MMKV/MMKV/MemoryFile.mm
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

using namespace std;

const int DEFAULT_MMAP_SIZE = getpagesize();
// 1MB per segment
constexpr uint32_t SegmentSize = 1024 * 1024;
// count of segments in memory
Expand Down

0 comments on commit ef4be36

Please sign in to comment.