Skip to content

Commit

Permalink
Merge pull request Tencent#241 from passerbyloo/dev
Browse files Browse the repository at this point in the history
fix typo
  • Loading branch information
lingol authored Apr 11, 2019
2 parents 6a02cb4 + ccd476e commit 12ebe7b
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions iOS/MMKV/MMKV/MMKV.mm
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ - (void)loadFromFile {
m_dic = [MiniPBCoder decodeContainerOfClass:NSMutableDictionary.class withValueClass:NSData.class fromData:inputBuffer];
m_output = new MiniCodedOutputData(m_ptr + offset + m_actualSize, m_size - offset - m_actualSize);
if (needFullWriteback) {
[self fullWriteback];
[self fullWriteBack];
}
} else {
[self writeActualSize:0];
Expand Down Expand Up @@ -453,7 +453,7 @@ - (void)trim {
return;
}

[self fullWriteback];
[self fullWriteBack];
auto oldSize = m_size;
while (m_size > (m_actualSize * 2)) {
m_size /= 2;
Expand Down Expand Up @@ -485,7 +485,7 @@ - (void)trim {
MMKVInfo(@"finish trim %@ to size %zu", m_mmapID, m_size);
}

- (BOOL)protectFromBackgroundWritting:(size_t)size writeBlock:(void (^)(MiniCodedOutputData *output))block {
- (BOOL)protectFromBackgroundWriting:(size_t)size writeBlock:(void (^)(MiniCodedOutputData *output))block {
if (m_isInBackground) {
static const int offset = pbFixed32Size(0);
static const int pagesize = getpagesize();
Expand Down Expand Up @@ -583,7 +583,7 @@ - (BOOL)ensureMemorySize:(size_t)newSize {

delete m_output;
m_output = new MiniCodedOutputData(m_ptr + offset, m_size - offset);
BOOL ret = [self protectFromBackgroundWritting:m_actualSize
BOOL ret = [self protectFromBackgroundWriting:m_actualSize
writeBlock:^(MiniCodedOutputData *output) {
output->writeRawData(data);
}];
Expand Down Expand Up @@ -659,7 +659,7 @@ - (BOOL)appendData:(NSData *)data forKey:(NSString *)key {
}
BOOL ret = [self writeActualSize:allData.length];
if (ret) {
ret = [self protectFromBackgroundWritting:m_actualSize
ret = [self protectFromBackgroundWriting:m_actualSize
writeBlock:^(MiniCodedOutputData *output) {
output->writeRawData(allData); // note: don't write size of data
}];
Expand All @@ -674,7 +674,7 @@ - (BOOL)appendData:(NSData *)data forKey:(NSString *)key {
BOOL ret = [self writeActualSize:m_actualSize + size];
if (ret) {
static const int offset = pbFixed32Size(0);
ret = [self protectFromBackgroundWritting:size
ret = [self protectFromBackgroundWriting:size
writeBlock:^(MiniCodedOutputData *output) {
output->writeString(key);
output->writeData(data); // note: write size of data
Expand All @@ -697,7 +697,7 @@ - (NSData *)getRawDataForKey:(NSString *)key {
return [m_dic objectForKey:key];
}

- (BOOL)fullWriteback {
- (BOOL)fullWriteBack {
CScopedLock lock(m_lock);
if (m_needLoadFromFile) {
return YES;
Expand Down Expand Up @@ -728,7 +728,7 @@ - (BOOL)fullWriteback {
if (ret) {
delete m_output;
m_output = new MiniCodedOutputData(m_ptr + offset, m_size - offset);
ret = [self protectFromBackgroundWritting:m_actualSize
ret = [self protectFromBackgroundWriting:m_actualSize
writeBlock:^(MiniCodedOutputData *output) {
output->writeRawData(allData); // note: don't write size of data
}];
Expand Down Expand Up @@ -884,22 +884,22 @@ - (BOOL)reKey:(NSData *)newKey {
delete m_cryptor;
auto ptr = (const unsigned char *) newKey.bytes;
m_cryptor = new AESCrypt(ptr, newKey.length);
return [self fullWriteback];
return [self fullWriteBack];
}
} else {
// decryption to plain text
MMKVInfo(@"reKey with no aes key");
delete m_cryptor;
m_cryptor = nullptr;
return [self fullWriteback];
return [self fullWriteBack];
}
} else {
if (newKey.length > 0) {
// transform plain text to encrypted text
MMKVInfo(@"reKey with aes key");
auto ptr = (const unsigned char *) newKey.bytes;
m_cryptor = new AESCrypt(ptr, newKey.length);
return [self fullWriteback];
return [self fullWriteBack];
} else {
return YES;
}
Expand Down Expand Up @@ -1299,7 +1299,7 @@ - (void)removeValuesForKeys:(NSArray *)arrKeys {

MMKVInfo(@"remove [%@] %lu keys, %lu remain", m_mmapID, (unsigned long) arrKeys.count, (unsigned long) m_dic.count);

[self fullWriteback];
[self fullWriteBack];
}

#pragma mark - Boring stuff
Expand Down

0 comments on commit 12ebe7b

Please sign in to comment.